1 posts
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.)
209 posts
Location
In your fridge.
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.
8 posts
Location
Sweden
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