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

[LUA|Error] Getting conditional statements to work

Started by Medza, 08 January 2013 - 07:18 AM
Medza #1
Posted 08 January 2013 - 08:18 AM
So I've been writing some code for a turtle where the turtle builds a little house and now I want it to go down the side of the building. However every time I get the 'end' expected to close the function. I tried moving about the ends, adding and removing them and normally it works but this is giving me some grief. Below is the code that I'm trying to use. Any help in pointing out my errors would be greatly appreciated. Thanks



function moveDown() 

if turtle.detectDown() then

turtle.turnRight()
turtle.turnRight()
end

else 

turtle.down()
moveDown()

end
Lyqyd #2
Posted 08 January 2013 - 08:22 AM
You have an end in the wrong place. If statements only have one end in total, at the very end of it. Move the end that's just before the else to just after the other end, so that it will close the function declaration.
Medza #3
Posted 08 January 2013 - 08:26 AM
Thank you very much that worked out fine