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

bios:206: [string "stair"] :8: 'then' expected

Started by gheotic, 27 December 2012 - 02:53 PM
gheotic #1
Posted 27 December 2012 - 03:53 PM
i keep getting this error
bios:206: [string "stair"] :8: 'then' expected

im just trying to make a mining turtle that makes a tower :)/>
can someone tell me why i get the error




local x = 0

turtle.forward()
turtle.forward()

while true do

if x = 4 then

turtle.up()

x = 0

end
else

turtle.placeDown()
turtle.forward()
turtle.placeDown()
turtle.forward()
turtle.placeDown()
turtle.forward()
turtle.placeDown()
turtle.forward()
x = x + 1
end
Luanub #2
Posted 27 December 2012 - 04:07 PM
What is the else for and the last end? I don't see an if statement and you can't have an else without and if and as far as I can see the only thing to end is your while loop which you already did so I think you can remove both.

Nevermind I missed the if. If has to do with the placement of you ends..

Here is the problem, using indentation helps a lot.

local x = 0

turtle.forward()
turtle.forward()

while true do
  if x = 4 then
    turtle.up()
    x = 0
  end -- this ends the if, move this down to where it is by the other end.
  else -- so this line errors since the if has already been ended.
  turtle.placeDown()
  turtle.forward()
  turtle.placeDown()
  turtle.forward()
  turtle.placeDown()
  turtle.forward()
  turtle.placeDown()
  turtle.forward()
  x = x + 1
end
Edited on 27 December 2012 - 03:10 PM
gheotic #3
Posted 27 December 2012 - 04:29 PM
i still get the same error :/
ChunLing #4
Posted 27 December 2012 - 04:29 PM
You didn't mention that "if x = 4 then" instead of "if x == 4 then". That's throwing the error.

But yeah, the else is also a problem.

You need to tell us what the tower is supposed to look like before we can help you much more. Right now it looks like a long staircase if you fix the errors mentioned.
Edited on 27 December 2012 - 03:32 PM
gheotic #5
Posted 27 December 2012 - 04:38 PM
ih i see lol :D/>
my plan is to make it go up a pipe with 2x2 free space in the middel
:P/> my bad
ChunLing #6
Posted 27 December 2012 - 11:02 PM
Yeah, you need to do something like:
for i=1,8 do
    for j=1,4 do
        for k=1,2 do
            turtle.placeDown()
            turtle.forward
        end
        turtle.turnLeft()
    end
    turtle.up()
end
If you want to go higher than 8, you'll need a bit of something in there to switch slots when you run low in the current slot.