Advertisement
proff001

Computercraft Door Multiple

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