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

Password program not working

Started by jcat321, 01 July 2012 - 05:58 PM
jcat321 #1
Posted 01 July 2012 - 07:58 PM
I'm trying to make a tekkit adventure map. It's just as much of a learning exercise as it is a project. But my passowrd door for a Nuclear Bunker isn't working. I'll paste the script. It might even just be a grammar error.


local side = "left"
local password = "Seven"
local opentime = 7
term.clear()
term.setCursorPos(1,1)
print ("--Nuclear Bunker interface--")
term.setCursorPos(1,3)
print ("Analysing exterior radiation. Please wait...")
sleep (3)
term.setCursorPos(1,5)
print ("Radiation detected!")
sleep (1)
write ("Measure:")
sleep (1)
write ("4'377Rads")
sleep (2)
term.setCursorPos(1,8)
write ("Bunker DoorSeal disabled in...")
sleep (1)
write ("Two months")
sleep (1)
term.setCursorPos(1,14)
print ("Prior DoorSeal disengagement requires override code")
sleep (1)
print ("Please enter override code or shutdown..")
sleep (1)
print ("Override code:")
localinput = read ("Seven")
if input == password then
term.clear()
term.setCursorPos(1,1)
print ("--Nuclear Bunker interface--")
print ("Code accepted")
sleep (1)
print ("Have a nice day!")
rs.setOutput(side,true)
sleep (opentime)
rs.setOutput(side,false)
os.shutdown
else
term.clear()
term.setCursorPos(1,1)
print ("--Nuclear Bunker interface--")
term.setCursorPos(1,3)
print ("Code invalid!")
sleep (4)
term.clear()
term.setCursorPos(1,1)
print ("--Nuclear Bunker interface--")
sleep (1)
term.setCursorPos(1,14)
print ("Please enter override code or shutdown..")

Thanks :P/>/>
MysticT #2
Posted 01 July 2012 - 08:56 PM
I think the problem is in this line:

localinput = read ("Seven")
there should be a space between "local" and "input". If that's not the problem, give us more details (like the error message or what's the problem) so we know what's going on.

Also, the argument to read(), must be a single character, and works as a replacement. So using read("*"), will make the screen show *****, when you type. It's usefull for passwords.
cant_delete_account #3
Posted 02 July 2012 - 04:49 PM
Change
localinput = read(blahblah)
To
local input = read(blahblah)
And change
os.shutdown
To
os.shutdown()