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

Door lock with password not working?

Started by LuffyNL, 07 July 2012 - 10:54 AM
LuffyNL #1
Posted 07 July 2012 - 12:54 PM
Ok, so i have a Computer with a password.
If it is correct the door will open for 5 seconds (Bottom output)
if it is incorrect a alarm will go off for 15 seconds (Back Output)

I typed:
edit startup

Then i wrote this:

local password = "Test"
local opentime = 5
term.clear()
term.setCursorPos(1,1)
write("Password: ")
local input = read(*)
if input == password then
term.clear()
term.setCursorPos(1,1)
print("Password Correct! Opening door...")
redstone.setOutput(bottom,true)
sleep(opentime)
redstone.setOutput(bottom,false)
os.reboot()
else
term.clear()
term.setCursorPos(1,1)
print("Password Incorrect! Activating alarm...")
redstone.setOutput(back,true)
sleep(15)
redstone.setOutput(back,false)
os.reboot()
end

Everything seems to be working fine untill you insert a password.

If it is Correct it shows this:

Password correct! Opening door…
startup:11: bad argument: string expected, got nil

If it is Incorrect it shows this:

Password Incorrect! Activating alarm…
startup:19: bad argument: string expected, got nil

Please help me.
LuffyNL #2
Posted 07 July 2012 - 12:57 PM
Nevermind i got it working now :P/>/>
I had to put "bottom" and "back"
instead of bottom and back
Derp :3