Advertisement
proff001

Computercraft Door

Jan 29th, 2021 (edited)
659
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.31 KB | None | 0 0
  1. -- Password for door
  2. local Pass = '123'
  3.  
  4. -- Admin Password Access to edit program
  5. local aPass = '1234'
  6.  
  7. -- If output normaly high or low
  8. local NormalyOutput = false
  9.  
  10. --Side to output (front,back,left,rigt,bottom,top)
  11. local output = 'back'
  12.  
  13. -- Disable CTRL + T
  14. -- Setting to false requires a reboot
  15. local DisableTermination = false
  16.  
  17. local input
  18. local Running = true
  19.  
  20. if DisableTermination then
  21.     os.pullEvent = os.pullEventRaw
  22. end
  23.  
  24. function NewText()
  25.     term.clear()
  26.     term.setCursorPos(1,1)
  27. end
  28.  
  29. function SetOutput(state)
  30.     if not state then
  31.         redstone.setOutput(output, NormalyOutput)
  32.     else
  33.         if NormalyOutput then
  34.             redstone.setOutput(output, not state)
  35.         else
  36.             redstone.setOutput(output, state)
  37.         end
  38.     end
  39. end
  40.  
  41. while Running do
  42.     SetOutput()
  43.     NewText()
  44.     print('Please Enter Password:')
  45.     input = read('*')
  46.  
  47.     if input == Pass then
  48.         NewText()
  49.         print('Opening...')
  50.         SetOutput(true)
  51.         sleep(2.5)
  52.         NewText()
  53.         print('Closing...')
  54.         SetOutput(false)
  55.         sleep(1)
  56.     elseif input == aPass then
  57.         NewText()
  58.         print('Welcome Admin')
  59.         Running = false
  60.     else
  61.         NewText()
  62.         print('Wrong Password')
  63.         sleep(2.5)
  64.     end
  65. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement