Posted 12 February 2013 - 11:24 PM
Title: [Error] Trouble with "while condition do"
Hello, the following program results in the error "bios:338: [string "startup"]:5: 'do' expected" and i'm unable to fix it. Changing line 5 to "while 1=1 do" still yielded the same error message. Any ideas why?
edit: Finally figured this out, it needed to be "==" instead of "=". But I still have no idea why, shouldn't "integer=integer" be true or false?
Hello, the following program results in the error "bios:338: [string "startup"]:5: 'do' expected" and i'm unable to fix it. Changing line 5 to "while 1=1 do" still yielded the same error message. Any ideas why?
edit: Finally figured this out, it needed to be "==" instead of "=". But I still have no idea why, shouldn't "integer=integer" be true or false?
Spoiler
-- coal in slot 16
i = 0
while true do
if turtle.getFuelLevel()>i*2+500 then
while turtle.getItemCount(15)=0 do
turtle.digDown()
turtle.suckDown()
turtle.digUp()
turtle.suckUp()
while not turtle.forward() do
turtle.dig()
turtle.suck()
end
i=i+1
end
turtle.turnRight()
turtle.turnRight()
end
while i>0 do
turtle.forward()
i=i-1
end
turtle.select(1)
turtle.drop()
turtle.select(2)
turtle.drop()
turtle.select(3)
turtle.drop()
turtle.select(4)
turtle.drop()
turtle.select(5)
turtle.drop()
turtle.select(6)
turtle.drop()
turtle.select(7)
turtle.drop()
turtle.select(8)
turtle.drop()
turtle.select(9)
turtle.drop()
turtle.select(10)
turtle.drop()
turtle.select(11)
turtle.drop()
turtle.select(12)
turtle.drop()
turtle.select(13)
turtle.drop()
turtle.select(14)
turtle.drop()
turtle.select(15)
turtle.drop()
turtle.select(16)
turtle.refuel(turtle.getItemCount(16)-1)
turtle.turnRight()
turtle.turnRight()
end