Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.pullEvent = os.pullEventRaw -- Makes it so that a hacker can't shut down your program by holding Ctrl + T.
- function clear() -- Creating a function that will clear the screen and reset the cursor.
- term.setCursorPos(1,1)
- term.clear()
- end
- clear()
- local password -- Defines a string containing the password to be used in the door.
- local termPass -- Defines a string containing the password needed to shutdown the program.
- local openTime -- Defines an integer to be used to set how long the door will be open.
- local availibleSides = {"top, ", "bottom, ", "left, ", "right, ", "front, ", "back", "\n"} -- Defines a table.
- local redstoneOutputSide -- Defines a string to be used to set the output of a redstone signal.
- local userInput -- Defines a string to be used with read().
- print("Please define your desired password:") -- Prints the string defined by the quote marks.
- password = read() --Setting the password string as whatever the user inputs.
- clear() -- Calling the function I made.
- print("Please define the password to be used to shut down the program.") -- Already explained.
- termPass = read() -- Already explained.
- clear() -- Already explained.
- print("Please define the amount of time the redstone pulse will be activated:") -- Already explained.
- openTime = tonumber(read()) -- Already explained.
- clear() -- Already explained.
- print("On which side will the redstone be activated?") -- Already explained.
- print("Availbe sides are:") -- Already explained.
- for i = 1, 7 do -- Loops through my tables and prints everything in it.
- write(availibleSides[i])
- end
- print("Please define a side:")
- redstoneOutputSide = read() -- Already explained.
- clear() -- Already explained.
- while true do -- The actual password door.
- clear()
- write("Please input password: ")
- userInput = read("*")
- if userInput == password then
- clear()
- print("Password is correct! Opening door...")
- rs.setOutput(redstoneOutputSide, true)
- sleep(openTime)
- rs.setOutput(redstoneOutputSide, false)
- elseif userInput == termPass then
- print("Shutting down computer, please wait...")
- sleep(2) -- Waits.
- os.shutdown()
- else
- print("Password is incorrect! Rebooting program...")
- sleep(2) -- Waits.
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement