Posted 20 October 2012 - 07:12 AM
Hey guys! I'm totally new to ComputerCraft, but I need it to work a certain function in my adventure map I'm making.
I'll tell you the scenario first so you can better understand it, then post my code, and finally the error I get.
So basically my map makes you go and find a floppy disk called Sburb Beta. Pretty simple. You return to your room where you have a computer asking for you to insert Sburb Beta into your disk drive. You insert it, and the computer sends a redstone signal out the back to a teleporter underneath you that teleports you to the next part of the map.
Now for the code:
Almost all credit for the code goes to Arkandos!
And last but not least my error message. The program seems to run fine as I set it to run on startup, and it displays the first message and everything, but when I insert the disk I get this message:
Welcome to Sburb Beta.
startup:12: attempt to call nil
From what I can tell, it does not send a signal, or do anything past printing the message.
Any help would be greatly appreciated! It is pretty hard for me to move on without this component of the map!
I'll tell you the scenario first so you can better understand it, then post my code, and finally the error I get.
So basically my map makes you go and find a floppy disk called Sburb Beta. Pretty simple. You return to your room where you have a computer asking for you to insert Sburb Beta into your disk drive. You insert it, and the computer sends a redstone signal out the back to a teleporter underneath you that teleports you to the next part of the map.
Now for the code:
term.clear()
term.setCursorPos(1, 1)
print("Insert Sburb Beta.")
while true do
event = os.pullEvent("disk")
sFile = "disk/pass"
hRead = assert(fs.open(sFile, "r"))
sPass = hRead.readLine()
hRead.close()
if sPass == "Enter" then
print("Welcome to Sburb Beta.")
redstone.setOuput("back", true)
sleep(3)
os.reboot()
else
print("Please try again!")
sleep(3)
os.reboot()
end
end
Almost all credit for the code goes to Arkandos!
And last but not least my error message. The program seems to run fine as I set it to run on startup, and it displays the first message and everything, but when I insert the disk I get this message:
Welcome to Sburb Beta.
startup:12: attempt to call nil
From what I can tell, it does not send a signal, or do anything past printing the message.
Any help would be greatly appreciated! It is pretty hard for me to move on without this component of the map!