Tables within tables, within tables...
Posted: Wed Mar 06, 2013 11:47 pm
I am trying to make a 2d, overhead-view game and I am having some problems with my map.
I want to create a map table that has an [x] and [y] dimension. However, I also want the map to be in layers. This way I could make layer 1 be the basement level, 2 be the floor, and 3 be a roof (or something similar to that). Unfortunately, love seems to crash every time I try to make one.
After some online research, I read that this should work:
For some reason, when I put this line of code anywhere in my project it force closes! I don't even get an error screen, it just closes .
...
After some more experimenting I found I the only way to form 3d+ tables (without crashing) was with this code:
(Code found on: http://www3.roblox.com/Forum/ShowPost.a ... D=46861712)
But when I try to call on it, It doesn't work! I've tried everything I can think of, including:
No matter what I try, I can't seem to find a solution that doesn't crash the program.
Anyway, if anybody knows how to make (and call from) 3d tables I would be very grateful. Google has a lot of working 2d examples, but no 3d ones that don't crash my game.
Thank you for taking the time to read this, I promise I spent a while trying to figure this out before coming to the forums .
I want to create a map table that has an [x] and [y] dimension. However, I also want the map to be in layers. This way I could make layer 1 be the basement level, 2 be the floor, and 3 be a roof (or something similar to that). Unfortunately, love seems to crash every time I try to make one.
After some online research, I read that this should work:
Code: Select all
Table = { {{1,1,1},{2,2,2},{3,3,3}}, {{4,4,4},{5,5,5},{6,6,6}} }
...
After some more experimenting I found I the only way to form 3d+ tables (without crashing) was with this code:
(Code found on: http://www3.roblox.com/Forum/ShowPost.a ... D=46861712)
Code: Select all
level = { }
for i= 1, 3 do -- 18
level[i] = { }
for j = 1, 18 do --
level[j] = { }
for m = 1, 18 do --
level[m] = { }
end
end
end
But when I try to call on it, It doesn't work! I've tried everything I can think of, including:
Code: Select all
level[x][y][z]
Code: Select all
local tempOne = level[x]
local tempTwo = tempOne[x]
local tempThree = tempTwo[x]
value = tempThree[x]
Code: Select all
for i,v in ipairs(level) do
for it, vt in ipairs(i[x]) do
return vt
end
end
Anyway, if anybody knows how to make (and call from) 3d tables I would be very grateful. Google has a lot of working 2d examples, but no 3d ones that don't crash my game.
Thank you for taking the time to read this, I promise I spent a while trying to figure this out before coming to the forums .