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

[Noob question] Really need help on this one!

Started by Snoepie1012, 26 September 2012 - 11:46 PM
Snoepie1012 #1
Posted 27 September 2012 - 01:46 AM
Hey guys, I know this is easy for the most of you but I am new to LUA and I been trying to fix this for a hour now so I decided to just ask it on the forums..

I have this simple code :



repeat

if turtle.detect() then
turtle.dig()
else
turtle.forward()
until 2 > 3

end
end

And it gives me the error :
bios:206: [string "test"]:7: 'end' expected (to close 'if' at line 3)

(Same error happends when I add or remove a 'end')

I dont get it, what am I doing wrong?

Thanks!
Snoepie1012 #2
Posted 27 September 2012 - 01:50 AM
I just fixed it!



repeat

if turtle.detect() then
turtle.dig()
else
turtle.forward()
end
until 2 > 3

Could someone explain why the 'end' has to be above the until? I mean its the end of all code right?
lieudusty #3
Posted 27 September 2012 - 02:38 AM
It has to have an end to end the if statement you stated at line 3.
GopherAtl #4
Posted 27 September 2012 - 02:56 AM
end does not mean end of the program, it means the end of some conditional or loop block within the program. Every if, while, and for statement must be followed by an end statement.