This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
ViperSRT3g's profile picture

[Solved] [Lua] [Error] Expected Symbol where there doesn't appear to need one

Started by ViperSRT3g, 17 December 2012 - 11:32 AM
ViperSRT3g #1
Posted 17 December 2012 - 12:32 PM
Hello all, I just started getting into Lua programming with Turtles and have run into an error that I'm not sure about. This code is just for simple digging methods.

Error: bios:206: [string "dig"]:32: '=' expected

Code:

direction=1
y=40
z=10

for w=1,z do
for x=1,y do
  if direction==1 then
   turtle.digUp()
   turtle.up()
  else
   turtle.digDown()
   turtle.down()
  end
end
turtle.dig()
turtle.forward()
changedir()
end

if direction==1 then
for x=1, y do
  turtle.down()
end
end

function changedir()
if direction==1 then
  direction=0
else
  direction=1
end
end

As far as I understand, it's saying that I need an '=' sign on the 32nd line, except that's the very last line of code.
Luanub #2
Posted 17 December 2012 - 12:41 PM
One problem is you call changedir() before it is declared. Remember Lua reads top down, if it hasn't read it, then it doesn't know it. Put the changedir() function up near the top of the code.
ViperSRT3g #3
Posted 17 December 2012 - 12:43 PM
I moved the changedir function right above the first of the for loops, and tested it, same error.

EDIT: Just noticed CC-Copy added in an extra 'd' at the very end of my script. Instead of end, it had typed in endd. Thanks though.