Hy there! currently i'm working on a "simple" animation system for my game. And i have some problems with tables. I made a settings file, to load the informations of the animations (to be specific, it loads the alias of the animation, and the number of frames it contains) so, my settings file looks like this: (animsettings.lua)
animlist = {idle, run}
animlist.idle = { frames, alias }
animlist.idle.frames = 1
animlist.idle.alias = "idle"
animlist.run = { frames, alias }
animlist.run.frames = 5
animlist.run.alias = "run"
And i want to access each animation's properties (frames, and alias) with their indexes like this: animlist[1][1], and that should be the value of animlist.idle.frames, which is 1. So, am I misunderstanding something, or this thing should work? because, when I try to print animlist[1][1] or animlist[1].frames, it prints a "nil" but when i print animlist.idle.frames, it prints the actual value which is 1.
So it loads the file correctly, but i can't seem to use their indexes.
Edit: I forgot to show, the function which tries to access these tables: The run animation contains 5 frames (per direction, so 1-r.png 2-r.png etc.) This function's purpose is to load the animation files and to add a table to player.anims so it'll be like this: player.anims.run.left , which gets its name from variables from the function which uses the resources from the animsettings.lua
function initAnims()
player.anims = {}
getAnimSettings('gfx/players/'..player.modelname..'/animsettings.lua')
for i = 1, #animlist do
for j = 1, #animlist[i][1] do
animlist[i][2] = {
left = ('gfx/players/'..player.modelname..'/'..animlist[i][2]..'/'..animlist[i]..j..'-l.png'),
right = ('gfx/players/'..player.modelname..'/'..animlist[i][2]'/'..animlist[i]..j..'-r.png')
}
table.insert(player.anims, animlist[i][2])
end
end
end
Edit2: now i realised that with this function every iteration i replace the actual frame with the next frame, so i'll make another table inside the that table that conatins each frame's data, but my question is still about the tables, and indexing, i think i'll be able to correct the function after that D: