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

Need some help...

Started by vira1969, 03 September 2012 - 03:59 PM
vira1969 #1
Posted 03 September 2012 - 05:59 PM
hello! i am currently trying to make a giant luxury spaceship,and the rooms are going to have fancy door locks in them.However,i need to make something to do this:when the computer is first acessed,i want it to have a text saying:"Insert your password here" or something like that.can someone help me?(if this is possible,anyways.)
Lettuce #2
Posted 03 September 2012 - 08:05 PM
Like this?

print "insert your password here:"
password = io.read()

etc.? Look up the CC wiki, it's on computercraft.info, or click News on the forums, then wiki. It has a tutorial for locks, in fact it's the first thing most do on CC.
SadProgrammer #3
Posted 03 September 2012 - 08:23 PM
Make a startup file by typing: edit startup

Then you should have code like this:

shell.run("clear") -- for the fancyness

side = "WhatEverSideYourDoorIsOn" -- May by right, left, back, top, bottom, front
password = "WhatEverYourPasswordIs" -- Put the password in this string

print "Provide your password, please: "
input = read("x")									  -- This will make you type in characters on the computers, like filling a field.

if input == password then					  -- Checking if the input is similar to the password
    print "Password Accepted."   
    redstone.setOutput(side, "true")	  -- Applying redstone current to whatever side you choose (to open doors and such)
    sleep(3)										    -- Waits...
    shell.run("shutdown")					    --Shuts down, to be opened again when you open the computer
else
    print "Incorrect Password"
    sleep(1.5)
    os.reboot()									   -- Restarts the password process