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

Stuck at EOF

Started by zaku2100, 24 December 2015 - 09:25 PM
zaku2100 #1
Posted 24 December 2015 - 10:25 PM
Well, i am mildly preturbed, with this code, i cant find whats wrong please help me.
The error im getting is
| Bios:338: [string "vault"]:30: '<eof>' expected. |
please help :|
Code starts here:
print("login")


print("user: ")
user = read()

print("pass")
pass = read("*")

if user == "1" and pass == "2" then
access = true
end

if access == "true" then
print("Access granted.")
sleep(1)
rs.setOutput("back",true)
rs.setOutput("left",true)
end

print("type close when you are done")
close = read()
if close == "close" then
print("i hope you got what you need in there.")
sleep(1)
rs.setOutput("back",false)
rs.setOutput("left",false)
os.reboot()
end

else
print("Invalid Login, rebooting…")
term.clear()
term.setCursorPos(1,1)
sleep(1)
os.shutdown()
end</eof>
Edited by
Bomb Bloke #2
Posted 25 December 2015 - 12:25 AM
You'll typically get that error when something's wrong with your "end"s. In this case, you're "end"ing an "if" block, and then attempting to "else" it - but you can't, as it's already finished!

It looks like you were going for this structure:

print("login")

print("user: ")
user = read()

print("pass")
pass = read("*")

if user == "1" and pass == "2" then
	access = true
end

if access == "true" then
	print("Access granted.")
	sleep(1)
	rs.setOutput("back",true)
	rs.setOutput("left",true)

	print("type close when you are done")
	close = read()
	
	if close == "close" then
		print("i hope you got what you need in there.")
		sleep(1)
		rs.setOutput("back",false)
		rs.setOutput("left",false)
		os.reboot()
	end

else
	print("Invalid Login, rebooting...")
	term.clear()
	term.setCursorPos(1,1)
	sleep(1)
	os.shutdown()
end

Note how the indentation makes it easy to tell where the "end"s should go.