so I'm new to lua and I cannot figure out how you target elements in arrays in arrays.
And is a table the same as an array? Why does an array and an object have the same syntax? Is there a difference?
Just use the table-indexing operator several times, e.g.:
local data = { { "northwest", "north", "northeast" },
{ "west", nil, "east" },
{ "southwest", "south", "southeast" } }
print(data[2][3]) -- prints east
As for the confusion regarding tables, arrays, objects, etc.: Lua has no ‘arrays’. Lua has no ‘objects’. For structure, Lua has only tables, which you can use as an array, or use as an object—but to Lua, it’s a table. They are what you make of them.
table.insert(tails, table.getn(tails), {x = snake.x, y = snake.y}) Targeting the table with: tails[1][1] and tails[1][2]x and y properties. Are you trying to get one of the objects by its x and y values?somex = tails[1][1] Which should refer to tails -> {{x=*10*, y =15},{x=5,y=10}}somex = tails[1]["x"], which Lua conveniently allows you to abbreviate to somex = tails[1].x.