Posted 02 March 2012 - 06:27 PM
So I've been writing this program now for a few hours already, it's called Trémauxbot (Trémaux as in the trémaux algorithm for solving mazes).
And I've stumbled upon this error message:
At line 621 is the following:
dir1 is assigned as a local variable at the top of my program (local dir1 = 0)
and move[x][y+1] are assigned at the top aswell using:
What could be the cause of this error, I've been staring at it for ages but still don't know what's wrong..
-Chub1337
P.S. The code around line 621 is:
And I've stumbled upon this error message:
tremauxbot : 621 : attempt to index ? (a function value)
At line 621 is the following:
dir1 = move[x][y+1]
dir1 is assigned as a local variable at the top of my program (local dir1 = 0)
and move[x][y+1] are assigned at the top aswell using:
--Table
write("Width of the maze in blocks?[x-coords] > ")
width = tonumber(read())
write("Height of the maze in blocks?[y-coords] > ")
height = tonumber(read())
maze = {}
for x=1,width,1 do
maze[x] = {}
end
for x=1,width,1 do
for y=1,height,1 do
maze[x][y] = 0
end
end
What could be the cause of this error, I've been staring at it for ages but still don't know what's wrong..
-Chub1337
P.S. The code around line 621 is:
Spoiler
elseif dir == 3 then
dir1 = move[x][y+1]
if forward == true then
dir2 = move[x][y-1]
if right == true then
dir3 = move[x-1][y]
else
dir3 = move[x+1][y]
end
else
dir2 = move[x-1][y]
dir3 = move[x+1][y]
end