Advertisement
Rolcam

ComputerCraft Door Lock (Advanced Version)

Jun 18th, 2020 (edited)
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.77 KB | None | 0 0
  1. -- Note this program can work standalone, but the alarm panel program is recommended as it's designed to be used with this lock.
  2. -- Note: This is designed for rednet cables, but bundled cables from other mods should work too.
  3.  
  4. -- Cabling Guide
  5. -- Back (Disregard if not using security program):
  6. -- Purple: Console Alarm Lock (from alarm panel/security monitor)
  7. -- Orange: Alarm Trigger (For alarm panel program)
  8. -- Right:
  9. -- White: Door Lock
  10. os.pullEvent = os.pullEventRaw    
  11. x=1
  12. -- Main Program
  13. while true do
  14. -- Resets Timer (for added security)
  15. timer = 30
  16. rs.setBundledOutput("back",0)
  17. rs.setBundledOutput("right",0)
  18. -- Alarm
  19. if x == 4 or redstone.testBundledInput("back", colors.purple) == true then
  20. while timer > 1 do
  21. term.clear()
  22. term.setCursorPos(1,1)
  23. term.setTextColor(colors.red)
  24. rs.setBundledOutput("back", colors.orange)
  25. -- Displays Text if cause is from password attempts
  26. if x == 4 then
  27. print("Access Attempts Exceeded")
  28. term.setCursorPos(1,2)
  29. end
  30. -- Countdown Timer
  31. term.write("Lockdown Triggered for ")
  32. term.write(timer)
  33. term.write(" seconds")
  34. sleep(1)
  35. timer = timer - 1
  36. end
  37. rs.setBundledOutput("back", 0)
  38. x=1
  39. end
  40. -- Password Screen
  41. term.clear()
  42. term.setCursorPos(1,1)
  43. term.setTextColor(colors.yellow)
  44. write("Demo Access")
  45. term.setCursorPos(1,3)
  46. print("Enter Password:")
  47. local input = read("*")
  48. -- Password Check
  49. if input == "demo" then
  50. term.setTextColor(colors.green)
  51. print("Password Accepted")
  52. x=1
  53. redstone.setBundledOutput("right", colors.white)
  54. sleep(3)
  55. redstone.setBundledOutput("right", 0)
  56. -- Operator/Override code for maintenance
  57. elseif input == "operator"
  58. term.setTextColor(colors.blue)
  59. print("Welcome Operator! Program Terminated!")
  60. break;
  61. else
  62. term.setTextColor(colors.red)
  63. print("Password Incorrect")
  64. x=x+1
  65. sleep(1)
  66. end
  67. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement