Difference between revisions of "Making a Password Protected Door"
(→How to make it) |
|||
Line 4: | Line 4: | ||
__TOC__ | __TOC__ | ||
− | + | this just happened to me and its ainnynog.if this happens to you here is the easier way to fix it.hold the button on top of your ipod and the home button for about 10 seconds this will shut down your ipod then after it shuts down hold the home button for a few seconds again and it will come back on. now its fixed | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
= Easier to understand code = | = Easier to understand code = |
Revision as of 14:18, 4 December 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.
this just happened to me and its ainnynog.if this happens to you here is the easier way to fix it.hold the button on top of your ipod and the home button for about 10 seconds this will shut down your ipod then after it shuts down hold the home button for a few seconds again and it will come back on. now its fixed
Easier to understand code
Type 'edit startup' and type in this code: (Use Ctrl + T to terminate the program, all code is explained in the comments, the --'s. It's good to read the comments, so you actually know what the code does, you do not need to have the comments in your code, of course)
local side = "left" -- Change left to whatever side your door / redstone is on, E.G: left, right, front, back, bottom, top. Be sure to leave the "s around it, though local password = "bacon" -- Change bacon to what you want your password to be. Be sure to leave the "s around it, though local opentime = 5 -- Change 5 to how long (in seconds) you want the redstone current to be on. Don't put "s around it, though while true do term.clear() -- Clears the screen term.setCursorPos(1,1) -- Fixes the cursor position write("Password: ") -- Prints 'Password: ' to the screen local input = read("*") -- Makes the variable 'input' have the contents of what the user types in, the "*" part censors out the password if input == password then -- Checks if the user inputted the correct password term.clear() -- Already explained up top term.setCursorPos(1,1) print("Password correct!") -- Prints 'Password correct!' to the screen rs.setOutput(side,true) -- Output a redstone current to the side you specified sleep(opentime) -- Wait the amount of seconds you specifed, then.. rs.setOutput(side,false) -- Stop outputting a redstone current else -- Checks if the user didn't input the correct password print("Password incorrect!") -- Prints 'Password incorrect!' to the screen sleep(2) -- Waits 2 seconds end end
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:
os.pullEvent = os.pullEventRaw
If you don't add this code to the top of your program, someone could terminate the lock and enter in a command and they can unlock your door without knowing the password. Adding the code is useful in Multiplayer.
To re-enable the ability to terminate the program, you must first make a copy of os.pullEvent, then you can restore it later.
local pullEvent = os.pullEvent os.pullEvent = os.pullEventRaw -- If the desired conditions are met, you can run this line to allow the program to be terminated. os.pullEvent = pullEvent