samuelask

security

Jan 23rd, 2021 (edited)
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.83 KB | None | 0 0
  1. c = require("component")
  2. local term = require("term")
  3. local component = require("component")
  4. event = require("event")
  5. os = require("os")
  6. event = require("event")
  7. computer = require("computer")
  8. serialization = require("serialization")
  9. local tun = component.tunnel
  10. modem = component.modem
  11. red = component.redstone
  12. local sides = require("sides")
  13. local colors = require("colors")
  14. local port = 125
  15. local asd = 1
  16. print("Security")
  17. print("--------------------------------------------------------------------------------------------------------------------------------------------------------------")
  18. print()
  19.  
  20. repeat
  21. modem.open(port)
  22. print("Listening for incoming alerts.")
  23. print()
  24.  
  25. local _, _, _, _, _, raw, address_raw = event.pull(nil, "modem_message")
  26. modem.close(port)
  27. print("Message recieved.")
  28. os.sleep(0.5)
  29.  
  30. if raw == "intruder" then
  31. print("Sound the alarms!")
  32. red.setBundledOutput(sides.north, { [colors.brown] = 15 } )
  33. red.setBundledOutput(sides.north, { [colors.cyan] = 15 } )
  34. os.sleep(1)
  35. elseif raw == "nointruder" then
  36. print("stopping alarms.")
  37. red.setBundledOutput(sides.north, { [colors.brown] = 0 } )
  38. red.setBundledOutput(sides.north, { [colors.cyan] = 0 } )
  39. os.sleep(1)
  40. elseif raw == "lockdown" then
  41. print("Lockdown initiated!.")
  42. red.setBundledOutput(sides.north, { [colors.green] = 15 } )
  43. os.sleep(1)
  44. elseif raw == "liftlockdown" then
  45. print("Lockdown lifted!.")
  46. red.setBundledOutput(sides.north, { [colors.green] = 0 } )
  47. os.sleep(1)
  48. elseif raw == "alarm+lock" then
  49. print("Lockdown initiated, alarms sounded!.")
  50. red.setBundledOutput(sides.north, { [colors.brown] = 15 } )
  51. red.setBundledOutput(sides.north, { [colors.cyan] = 15 } )
  52. red.setBundledOutput(sides.north, { [colors.green] = 15 } )
  53. os.sleep(1)
  54. elseif raw == "liftalarm+lock" then
  55. print("Lockdown lifted, alarms off!.")
  56. red.setBundledOutput(sides.north, { [colors.brown] = 0 } )
  57. red.setBundledOutput(sides.north, { [colors.cyan] = 0 } )
  58. red.setBundledOutput(sides.north, { [colors.green] = 0 } )
  59. os.sleep(1)
  60. elseif raw == "alarmson" then
  61. print("Alarms on!.")
  62. red.setBundledOutput(sides.north, { [colors.brown] = 15 } )
  63. os.sleep(1)
  64. elseif raw == "alarmsoff" then
  65. print("Alarms off!.")
  66. red.setBundledOutput(sides.north, { [colors.brown] = 0 } )
  67. os.sleep(1)
  68. elseif raw == "turretson" then
  69. print("Turrets on.")
  70. red.setBundledOutput(sides.north, { [colors.cyan] = 15 } )
  71. os.sleep(1)
  72. elseif raw == "turretsoff" then
  73. print("Turrets off.")
  74. red.setBundledOutput(sides.north, { [colors.cyan] = 0 } )
  75. os.sleep(1)
  76. elseif raw == "alarm+turret" then
  77. print("Sounding alarms and activating turrets.")
  78. red.setBundledOutput(sides.north, { [colors.brown] = 15 } )
  79. red.setBundledOutput(sides.north, { [colors.cyan] = 15 } )
  80. os.sleep(1)
  81. end
  82. until asd == 2
Add Comment
Please, Sign In to add comment