I was making a move cell that moved in the direction it was facing, and made a script (below) that removes itself from the map, and sets the id of the tile in it's way to a move cell (which is 2). To do this, I just got the previous key and added 1 to it. According to LOVE/Lua, the next key in the table (also below), is nil (or at least that's what I understood).
Exception / Error Message:
Code: Select all
Error
main.lua:25: attempt to index a nil value
Traceback
[love "callbacks.lua"]:228: in function 'handler'
main.lua:25: in function 'Step'
main.lua:49: in function 'update'
[love "callbacks.lua"]:162: in function <[love "callbacks.lua"]:144>
[C]: in function 'xpcall'
Code: Select all
for k, v in pairs(map) do -- Prioritize Move Tiles first to prevent a lot of issues
for k1, v1 in pairs(v) do
if v1[1] == 2 then -- v1[1] is ID, v1[2] is DIRECTION. 1 is right, 2 is down, 3 is left, and so on.
if v1[2] == 1 then
v1[1] = 0
v[k1+5][1] = 2
end
end
end
end
Code: Select all
local map = {
{t(0),t(2),t(0),t(0),t(0),}