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

Else problem :(

Started by Xxcookid123xX, 13 December 2015 - 01:24 AM
Xxcookid123xX #1
Posted 13 December 2015 - 02:24 AM
Ok so i really need help, i have a program that opens and shuts me and my friend's door. It works, but when i add this it fails:

else
print "Unknown command."
sleep(1)
shell.run("startup")

I am using 1.7.10, by the way.

Whole thing:

term.setBackGroundColor(colors.pink)
term.setTextColor(colors.white)
shell.run("clear")
print "Hi, what would you like to do?"
print "Options: Open, Close."
print "To exit, Type anything and press enter." (because the else doesnt work)
option = read()
if option == "open" then
shell.run("open")
sleep(0.5)
print "Doors open."
sleep(1)
shell.run("startup")
end
elseif option == "close" then
shell.run("close")
sleep(0.5)
print "Doors closed."
end
else
print "Unknown command."
sleep(1)
shell.run("startup")


Thats all. Heres the error message:

bios:14: [string "startup"]:15: '<eof>' expected

Thanks.
KingofGamesYami #2
Posted 13 December 2015 - 03:12 AM
You have too many ends. One end is required per if statement, like so:


if foo < bar then

elseif foo > bar then

else

end