Advertisement
karelvysinka

Door password computercraft EN

Nov 15th, 2023
1,114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Configuration
  2. local password = "secretPassword"  -- Set your secret password here
  3. local doorSide = "left"  -- Set the side where the door is located (left, right, front, back, top, bottom)
  4.  
  5. -- Decoration function
  6. function decorate()
  7.     print("****************************************")
  8.     print("*                                      *")
  9.     print("*     Welcome to the Security System   *")
  10.     print("*                                      *")
  11.     print("****************************************")
  12. end
  13.  
  14. -- Main program
  15. while true do
  16.     decorate()
  17.     print("Enter password to open the door:")
  18.     local enteredPassword = read("*") -- Password will not be shown when typing
  19.  
  20.     if enteredPassword == password then
  21.         print("Password correct. Opening door...")
  22.         redstone.setOutput(doorSide, true)  -- Opens the door
  23.         sleep(5)  -- Wait for 5 seconds
  24.         redstone.setOutput(doorSide, false) -- Closes the door
  25.         print("Door closed.")
  26.     else
  27.         print("Incorrect password.")
  28.     end
  29.  
  30.     print("Waiting for the next attempt...")
  31.     sleep(3) -- Wait for 3 seconds before the next attempt
  32. end
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement