Prerequisites:
Computer
Iron Door
Place the computer to the right of the iron door.
Right click the computer to open the terminal.
Create a new file by typing "edit password" (You can replace password with whatever filename you wish)
With the text editor open, type in the following script;
local pw = ""<br />local running = true
This code sets up the two required variables. The first is a string that is used to validate the password. The second is a boolean that informs the program if it should keep going.
while running == true do<br /> term.clear()<br /> write("Please Enter the Password:")<br /> pw = read()
This starts the program loop. term.clear() clears all text on the screen. The program then writes a message and read() reads user input into the pw variable.
if pw == "furry" then<br /> rs.setOutput("left", true)<br /> sleep(7)<br /> rs.setOutput("left", false)<br /> end
This section tests if the password is correct. If you wish to change the password, change "furry" to whatever you wish. The script then opens the door, waits 7 seconds, and then closes it again. Note: if the door is on the right, change "left" to "right" on both functions.
if pw == "secretclosephrase" then<br /> running = false<br /> end<br />end
This final bit gives us an easy way to exit the program. If the user types "secretclosephrase" instead of the password, the program will close.
Hit the Control key, and use the arrow keys to choose [Save]. Hit control again and close the program. Type "password" into the terminal, and your program should run.
All of the script together:
local pw = ""<br />local running = true<br />while running == true do<br /> term.clear()<br /> write("Please Enter the Password:")<br /> pw = read()<br /> if pw == "furry" then<br /> rs.setOutput("left", true)<br /> sleep(7)<br /> rs.setOutput("left", false)<br /> end<br /> if pw == "secretclosephrase" then<br /> running = false<br /> end<br />end<br />