I’m used to Javascript and the ability to create arrays and objects like so:
var bar = [];
var currentBeats;
bar[1] = {beats:4, subdivisions:2};
bar[2] = {beats:2, subdivisions:2};
bar[3] = {beats:3, subdivisions:2};
--Access or set an index
currentBeats = bar[3].beats --returns 3
Sorry for the simplicity of this, but I’m a bit stuck: how do you pull this off in Lua? I’ve attempted this to no success:
local bar = {}
table.insert(bar["beats"], 4)
table.insert(bar["beats"], 2)
table.insert(bar["beats"], 3)
I too am a luanoob, but had a similar issue. I wanted to store a “table of arrays” Lua’s combination of key=value pairs and dot syntax make tables really easy and flexible. I found these links really helpful.