Difference between revisions of "Making a Password Protected Door"
(→Stop people from terminating your lock) |
|||
Line 54: | Line 54: | ||
</pre> | </pre> | ||
− | The eighth line turns OFF the redstone current on the line, thus closing the door. The | + | The eighth line turns OFF the redstone current on the line, thus closing the door. The ninth line indicates that if the password ISN'T correct, that it will print Incorrect Password. The final two lines end the program. |
= Stop people from terminating your lock = | = Stop people from terminating your lock = | ||
Line 63: | Line 63: | ||
Okay, so now you want to CHANGE the program, but you can't. Here's the simple fix: Make a new computer and a disk drive. Get a floppy disk and put it in a disk drive that is adjacent to the new computer. Now, type in the computer | Okay, so now you want to CHANGE the program, but you can't. Here's the simple fix: Make a new computer and a disk drive. Get a floppy disk and put it in a disk drive that is adjacent to the new computer. Now, type in the computer | ||
edit disk/startup. this will make it so you can make it so it runs the disk's program on CPU startup. Now type in it print ("Hello World"). now save the program..... now, get that disk drive and put it NEXT to that computer. Then, put in the disk and enter the computer and do CTRL + R. the message "Hello World" should appear on the screen, allowing access to the startup file again. | edit disk/startup. this will make it so you can make it so it runs the disk's program on CPU startup. Now type in it print ("Hello World"). now save the program..... now, get that disk drive and put it NEXT to that computer. Then, put in the disk and enter the computer and do CTRL + R. the message "Hello World" should appear on the screen, allowing access to the startup file again. | ||
+ | |||
+ | = Turning the password into asterisks = | ||
+ | Replace the | ||
+ | input = read() | ||
+ | line with | ||
+ | input = read("*") | ||
+ | |||
+ | Now when you write your password it should show up as asterisks. | ||
Revision as of 14:34, 24 July 2012
This tutorial covers on how to make a computer output redstone current when the right password is typed in. The current is then used to trigger an iron door.
Contents
How to make it
A password protected door is actually pretty easy, if you break it into steps.
First, you need to craft a computer, and connect the back to an iron door with redstone, or just have a Computer next to the door.
Once you're done with the basics, open the computer and edit the "startup" file. (type in 'edit startup') This will make it so the program will be executed when the computer boots.
Once you access the startup file, enter in these five lines.
while true do print ("Enter Password") input = read()
The first line opens a loop that will continue running forever. The second lines "Prints" the message Enter Password on the screen. you can get rid of this if it's not wanted. The third line is used to change what the characters you type into the computer appear as. If you put ("*") after read, then it will appear in asterisks, While leaving it as is will show the password.
Here are the next few lines added on:
while true do print ("Enter Password") input = read() if input == "password" then print ("Password Accepted") rs.setOutput("right", true) sleep()
The fourth line makes it so that if the word PASSWORD is typed, that it will go on to next steps. change the word "Password" to your desired password. The fifth line tells the computer to print Password Accepted if you correctly input the password. The sixth line outputs a redstone current on the given side. change "right" to the side you want to output a current. the seventh line tells the computer to halt the program for the given amount of time (Meaning it keeps door open for that amount of time)
now, for the FINAL lines.
while true do print ("Enter Password") input = read() if input == "password" then print ("Password Accepted") rs.setOutput("right", true) sleep() rs.setOutput("right", false) else print ("Incorrect Password") end end
The eighth line turns OFF the redstone current on the line, thus closing the door. The ninth line indicates that if the password ISN'T correct, that it will print Incorrect Password. The final two lines end the program.
Stop people from terminating your lock
If you don't want people holding CTRL+T and quitting your lock, use this code at the top of your program (Note: This makes it so that you CANNOT access it by normal means):
os.pullEvent = os.pullEventRaw
Okay, so now you want to CHANGE the program, but you can't. Here's the simple fix: Make a new computer and a disk drive. Get a floppy disk and put it in a disk drive that is adjacent to the new computer. Now, type in the computer edit disk/startup. this will make it so you can make it so it runs the disk's program on CPU startup. Now type in it print ("Hello World"). now save the program..... now, get that disk drive and put it NEXT to that computer. Then, put in the disk and enter the computer and do CTRL + R. the message "Hello World" should appear on the screen, allowing access to the startup file again.
Turning the password into asterisks
Replace the
input = read()
line with
input = read("*")
Now when you write your password it should show up as asterisks.