25 posts
Posted 19 April 2013 - 11:24 AM
Hey guys, I'm creating housing for R-Loyalists in Minecraft. I am creating a door computer, however, it keeps giving me the error "bios:337: [string "startup"]:15: <eof> expected. Here's what I have so far.
term.clear()
term.setCursorPos(1,1)
print("What is your rank, USER?")
print(" ")
term.setTextColor(colors.green)
print("Citizen | CWU | MetroPolice |")
print("Security | Admin | Mechanic |")
term.setTextColor(colors.white)
write(">> ")
if input == "Citizen" then
print("You do not have access!")
os.reboot()
end
elseif input == "CWU" then
print("Welcome!")
end
elseif input == "MetroPolice" then
print("Welcome!")
end
elseif input == "Admin" then
print("Welcome, Administraitor Crontic!")
end
elseif input == "Mechanic" then
print("Welcome. Your screen usage is being recorded.")
end
else
print("Pardon? I dont understand.")
os.reboot()
end
1522 posts
Location
The Netherlands
Posted 19 April 2013 - 11:28 AM
You have quite a lot ends too much.
This is what a if statement should look like:
if something then
--do stuff
elseif somethingElse then
--do stuff
end
So you close the statement once, not multiple times. Just remove the ends in your code and keep the last one :)/>
1852 posts
Location
Sweden
Posted 19 April 2013 - 11:36 AM
Do as Engineer said and remove every end except the last one
since when it's elseif it still counts as one end you need for the if statement and not a new one.
25 posts
Posted 19 April 2013 - 11:51 AM
The program runs, but with the 'else', it gives me that message and doesn't let me type.
1214 posts
Location
The Sammich Kingdom
Posted 19 April 2013 - 11:57 AM
Fixed code.
term.clear()
term.setCursorPos(1,1)
print("What is your rank, USER?")
print(" ")
term.setTextColor(colors.green)
print("Citizen | CWU | MetroPolice |")
print("Security | Admin | Mechanic |")
term.setTextColor(colors.white)
write(">> ")
local input = read()
if input == "Citizen" then
print("You do not have access!")
os.reboot()
elseif input == "CWU" then
print("Welcome!")
elseif input == "MetroPolice" then
print("Welcome!")
elseif input == "Admin" then
print("Welcome, Administraitor Crontic!")
elseif input == "Mechanic" then
print("Welcome. Your screen usage is being recorded.")
else
print("Pardon? I dont understand.")
os.reboot()
end
You also forgot to define the input var.
15 posts
Posted 19 April 2013 - 12:18 PM
Fixed code.
term.clear()
term.setCursorPos(1,1)
print("What is your rank, USER?")
print(" ")
term.setTextColor(colors.green)
print("Citizen | CWU | MetroPolice |")
print("Security | Admin | Mechanic |")
term.setTextColor(colors.white)
write(">> ")
local input = read()
if input == "Citizen" then
print("You do not have access!")
os.reboot()
elseif input == "CWU" then
print("Welcome!")
elseif input == "MetroPolice" then
print("Welcome!")
elseif input == "Admin" then
print("Welcome, Administraitor Crontic!")
elseif input == "Mechanic" then
print("Welcome. Your screen usage is being recorded.")
else
print("Pardon? I dont understand.")
os.reboot()
end
You also forgot to define the input var.
I noticed that the "Pardon? I dont understand." will appear as if it's not showing since the os.reboot() is called right after.
Here's a fix so you don't need to os.reboot()
Spoiler
auth = "no"
while auth == "no" do
auth = ""
term.clear()
term.setCursorPos(1,1)
print("What is your rank, USER?")
print(" ")
term.setTextColor(colors.green)
print("Citizen | CWU | MetroPolice |")
print("Security | Admin | Mechanic |")
term.setTextColor(colors.white)
write(">> ")
local input = read()
if input == "Citizen" then
print("You do not have access!")
sleep(2)
elseif input == "CWU" then
print("Welcome!")
elseif input == "MetroPolice" then
print("Welcome!")
elseif input == "Admin" then
print("Welcome, Administraitor Crontic!")
elseif input == "Mechanic" then
print("Welcome. Your screen usage is being recorded.")
else
print("Pardon? I dont understand.")
sleep(2)
auth = "no"
end
end
Edited: Forgot to put in sleep() & remove os.reboot()