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

<eof> Error

Started by SkyCrafter0, 20 May 2017 - 09:43 PM
SkyCrafter0 #1
Posted 20 May 2017 - 11:43 PM
So im making a program that password protects pocket computer, so it checks if the password is 'MasterKey', and if its not, it checks if it is 'password1', and if not, it reboots.
Im getting and EOF error on line 11, can someone help me?
(Not sure how to do spoiler)
Code:
os.pullEvent = os.pullEventRaw
while true do
term.clear()
term.setCursorPos(1,1)
term.write("Password:")
local password = read()
if password == "MasterKey" then
shell.run("ID")
end
end
elseif password == "password1" then
shell.run("ID")
end
end
else
term.print("Incorrect.Rebooting")
sleep(5)
os.reboot
end
end
end
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
can someone fix my code and help me? i've been tinkering with it for like an hour now
Bomb Bloke #2
Posted 21 May 2017 - 05:06 AM
You can't "else" an "if" you've already "end"ed.

os.pullEvent = os.pullEventRaw

while true do
	term.clear()
	term.setCursorPos(1,1)
	term.write("Password:")
	local password = read()
	
	if password == "MasterKey" then
		shell.run("ID")
	elseif password == "password1" then
		shell.run("ID")
	else
		term.print("Incorrect.Rebooting")
		sleep(5)
		os.reboot
	end
end
SkyCrafter0 #3
Posted 22 May 2017 - 01:10 AM
Thx :D/>
I've tried to fix this for legit 6 hours