Jump to content




[LUA|Error] Getting conditional statements to work


  • You cannot reply to this topic
2 replies to this topic

#1 Medza

  • New Members
  • 2 posts

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


#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

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.

#3 Medza

  • New Members
  • 2 posts

Posted 08 January 2013 - 08:26 AM

Thank you very much that worked out fine





3 user(s) are reading this topic

0 members, 3 guests, 0 anonymous users