Hi! I'm Trying to make a login program. But When i try to run it i get this error: bios:338: [string "startup"]:27 'end' expected (to close 'if' at line 13) how do i fix it? Heres My code:
local pullEvent = os.pullEvent
os.pullEvent = os.pullEventRaw
local scode = "1525"
local code = "8126"
local out = "back"
local time = 5
term.clear()
term.setCursorPos(1,1)
write("Please input code> ")
local input = read("*")
if input == code then
t
term.clear()
term.setCursorPos(1,1)
print("Correct code!")
rs.setOutput(out, true)
sleep(time)
rs.setOutput(out, false)
os.reboot()
else
term.clear()
term.setCursorPos(1,1)
print("Incorrect code!")
sleep(2)
os.reboot()
elseif input == scode then
os.pullEvent = pullEvent
print("You can terminate the program now")
end
bios:338: [string "startup"]:27 'end' expected
Started by Mackan90096, Feb 23 2013 12:21 AM
7 replies to this topic
#1
Posted 23 February 2013 - 12:21 AM
#2
Posted 23 February 2013 - 04:27 AM
Split into new topic.
Your elseif clause needs to be before your else clause.
Your elseif clause needs to be before your else clause.
#3
Posted 23 February 2013 - 09:17 AM
Use pastebin or something damnit. Most people don't even bother reading your code if it's not formatted.
#4
Posted 23 February 2013 - 09:52 AM
Lyquid already told you what to do, but in case you don't understand here is the fixed code, just copy%paste it.
And next time please format your code correctly, and use pastebin or code (<>) option in the editor.
local pullEvent = os.pullEvent
os.pullEvent = os.pullEventRaw
-- [[ Variables ]] --
local scode = "1525"
local code = "8126"
local out = "back"
local time = 5
-- [[ Main Part ]] --
term.clear()
term.setCursorPos(1,1)
write("Please input code> ")
local input = read("*")
if input == code then
term.clear()
term.setCursorPos(1,1)
print("Correct code!")
rs.setOutput(out, true)
sleep(time)
rs.setOutput(out, false)
os.reboot()
elseif input == scode then
os.pullEvent = pullEvent
print("You can terminate the program now")
else
term.clear()
term.setCursorPos(1,1)
print("Incorrect code!")
sleep(2)
os.reboot()
end
And next time please format your code correctly, and use pastebin or code (<>) option in the editor.
#5
Posted 23 February 2013 - 10:08 AM
Formatted and bugfixed version of the code:
Code that I prefer to use:
EDIT: Yay ninja'd
Spoiler
Code that I prefer to use:
Spoiler
EDIT: Yay ninja'd
#6
Posted 24 February 2013 - 10:02 AM
Don't want to sound like an idiot. But shouldn't the 3rd to last line be
os.pullEvent = os.pullEventRaw
os.pullEvent = os.pullEventRaw
#7
Posted 24 February 2013 - 11:31 AM
Lewis.holcombe, on 24 February 2013 - 10:02 AM, said:
Don't want to sound like an idiot. But shouldn't the 3rd to last line be
os.pullEvent = os.pullEventRaw
os.pullEvent = os.pullEventRaw
Nope. With os.pullEvent = pullEvent, he restores the good old os.pullEvent, because it points to os.pullEventRaw before that.
pullEvent (not os.pullEvent but pullEvent) is declared on the 1st line, and it points to the old os.pullEvent.
#8
Posted 25 February 2013 - 07:16 PM
Thanks for The help!
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











