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

[Error] [Lua] bios: 206: [string "forward"]:30: '=' expected

Started by Cortcase, 15 June 2012 - 03:42 AM
Cortcase #1
Posted 15 June 2012 - 05:42 AM
So I can't seem to find the error here. I'm brand new to code but I think my logic is solid and its just a syntactical error. The program is supposed to dig a branch mine 2 blocks high, 41 blocks wide(20 to either side), and 10 branches long (40 blocks deep). The error returned is in my title. The program title is 'forward.' Any help would be appreciated.

local x, z = 0, 0
function forward2()
   if turtle.forward() ==false then
	  repeat
	  turtle.dig()
	  sleep(0.25)
	  until turtle.forward() == true
   end
   if turtle.up() == false then
	  repeat
	  turtle.digUp()
	  sleep(0.25)
	  until turtle.up() == true
   end
   if turtle.forward() ==false then
	  repeat
	  turtle.dig()
	  sleep(0.25)
	  until turtle.forward() == true
   end
   turtle.digDown()
   turtle.down()
end
if z < 10 then
   forward2()
   forward2()
   turtle.turnLef()
   repeat
	  forward2
	  x + 2
	  until x == 20
   end
   turtle.turnRight()
   turtle.turnRight()
   repeat
	  turtle.forward()
	  x - 1
	  until x == 0
   end
   repeat
	  forward2
	  x + 2
	  until x == 20
   end
   turtle.turnLeft()
   turtle.turnLeft()
   repeat
	  turtle.forward()
	  x - 1
	  until x == 0
   end
   turtle.turnRight()
   z + 1
end
if z == 10 then
   turtle.turnLeft()
   turtle.turnLeft()
   for i=1, 40 do
	  turtle.forward()
end
BigSHinyToys #2
Posted 15 June 2012 - 09:03 AM
fixed
a few functions were missing there () brackets and also x -1 is not correct to make x lower by one you have to use x = x-1
Spoiler

local x, z = 0, 0
function forward2()
    if turtle.forward() == false then
	    repeat
		    turtle.dig()
		    sleep(0.25)
	    until turtle.forward() == true
    end
   if turtle.up() == false then
	    repeat
		    turtle.digUp()
		    sleep(0.25)
	    until turtle.up() == true
    end
    if turtle.forward() == false then
	    repeat
		    turtle.dig()
		    sleep(0.25)
	    until turtle.forward() == true
    end
    turtle.digDown()
    turtle.down()
end
if z < 10 then
    forward2()
    forward2()
    turtle.turnLeft()
    repeat
	    forward2()
	    x = x + 2
    until x == 20
    turtle.turnRight()
    turtle.turnRight()
    repeat
	    turtle.forward()
	    x = x - 1
    until x == 0
    repeat
	    forward2()
	    x = x + 2
    until x == 20
    turtle.turnLeft()
    turtle.turnLeft()
    repeat
	    turtle.forward()
	    x = x - 1
    until x == 0
    turtle.turnRight()
    z = z + 1
end
if z == 10 then
    turtle.turnLeft()
    turtle.turnLeft()
    for i=1, 40 do
	    turtle.forward()
    end
end