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

[lua] [error] :35: <eof> expected

Started by sjele, 26 July 2012 - 11:56 AM
sjele #1
Posted 26 July 2012 - 01:56 PM
So i have been trying to make a hotel, and i want a computer at each lvl to open the correct door, here is the code for first floor with rooms. But i get the error stated in the title. So i would like some help as this is my first "big" programming, my highest before this was 15. I'm sorry i forgot line jumps inbetween each part of code. Program is called context, beacuse this is my first time using this program to code.

It would be nice if you could spot any other error for me to :)/>/>


os.pullEvent = os.pullEventRaw
print("Loadning")
sleep(2)
print("----------------------")
print("Done loading")
print("Press E to continue")
local event, param = os.pullEvent("char")
param = "e"
if true then
print("Choose a number between 1-5")
write("Insert number:  ")
input = read()
end
door1  = "1"
door2 = "2"
door3 = "3"
door4 = "4"
door5 = "5"
yes = "yes"
no = "no"
if input == door1 then
print("1 is chosen")
print("Door is opening")
rs.setBundledOutput ("back", colors.red)
sleep(5)
term.clear()
term.setCursorPos(1,1)
shell.run(context)
end
elseif input == door2 then
print("2 is chosen")
print("Door is opening")
rs.setBundledOutput ("back", colors.yellow)
sleep(5)
term.clear()
term.setCursorPos(1,1)
shell.run(context)
end
elseif input == door3 then
print("3 is chosen")
print("Door is opening")
rs.setBundledOutput ("back", colors.blue)
sleep(5)
term.clear()
term.setCursorPos(1,1)
shell.run(context)
end
elseif input == door4 then
print("4 is chosen")
print("Door is opening")
rs.setBundledOutput ("back", colors.lime)
sleep(5)
term.clear()
term.setCursorPos(1,1)
shell.run(context)
end
elseif input == door5 then
print("5 is chosen")
print("Door is opening")
rs.setBundledOutput ("back", colors.black)
sleep(5)
term.clear()
term.setCursorPos(1,1)
shell.run(context)
end
else
print("Wrong door number, no door is opening!")
sleep(3)
print("Is this understood")
write("yes or no: ")
input = read()
if input == yes then
print("Remember to use correct room number next time")
sleep(3)
print("Door selector is restarting! This will take a few seconds")
sleep(2)
term.clear()
term.setCursorPos(1,1)
shell.run(context)
elseif input == no then
print("I'll take it as a yes")
sleep(3)
print("Door selector is restarting! This will take a few seconds")
sleep(2)
term.clear()
term.setCursorPos(1,1)
shell.run(context)
end
Watcher7 #2
Posted 26 July 2012 - 02:40 PM
http://pastebin.com/Y9kxy062
M'kay so here's the deal, formatting is VERY important. I normally don't do this for people, but it's just formatting so there's the pastebin. But I didn't fix every-thing, I don't think I saw you define context, and I'm pretty sure shell.run takes a string, not plain-text/undefined-var.
sjele #3
Posted 26 July 2012 - 02:42 PM
Thank you. I'll try the code :)/>/>
BigSHinyToys #4
Posted 26 July 2012 - 02:55 PM
So I have made some huge changes to your code If you have any problems please just ask i will be happy to explain
Spoiler

os.pullEvent = os.pullEventRaw
door1  = "1" -- best to put varibles at top
door2 = "2"
door3 = "3"
door4 = "4"
door5 = "5"
yes = "yes"
no = "no"
local sSide = "back" --  makes it easer to change latter if nessasary
while true do
	term.clear()
	term.setCursorPos(1,1)
	rs.setBundledOutput (sSide,0) -- turns off all colors
  
	print("Loading") -- spell fix
	sleep(2)
	print("----------------------")
	print("Done loading")
	print([[Press "e" to continue]])
	while true do
		local event, param = os.pullEvent("char")
		if param == "e" then
			break
		end
	end
	print("Choose a number between 1-5")
	write("Insert number:  ")
	input = read()
	if input == door1 then
		print("1 is chosen")
		print("Door is opening")
		rs.setBundledOutput (sSide, colors.red)
		sleep(5)
	elseif input == door2 then
		print("2 is chosen")
		print("Door is opening")
		rs.setBundledOutput (sSide, colors.yellow)
		sleep(5)
	elseif input == door3 then
		print("3 is chosen")
		print("Door is opening")
		rs.setBundledOutput (sSide, colors.blue)
		sleep(5)
	elseif input == door4 then
		print("4 is chosen")
		print("Door is opening")
		rs.setBundledOutput (sSide, colors.lime)
		sleep(5)
	elseif input == door5 then
		print("5 is chosen")
		print("Door is opening")
		rs.setBundledOutput (sSide, colors.black)
		sleep(5)
	else
		print("Wrong door number, no door is opening!")
		sleep(3)
		print("Is this understood")
		write("yes or no: ")
		input = read()
	end
	if input == yes then
		print("Remember to use correct room number next time")
		sleep(3)
		print("Door selector is restarting! This will take a few seconds")
		sleep(2)
	elseif input == no then
		print("I'll take it as a yes")
		sleep(3)
		print("Door selector is restarting! This will take a few seconds")
		sleep(2)
	end
end
[EDIT]
looks like i was beat lol XD
sjele #5
Posted 26 July 2012 - 06:21 PM
I've got code working now, thanks for you're help :)/>/>