Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.11 KB | None | 0 0
  1. -- right is door
  2. -- back is alarm
  3. -- left is sensor
  4. -- MAKE SURE TO CLEAR MONITOR FIRST BEFORE WRITING
  5.  
  6. -----------------
  7. -- Door & Alarm--
  8. -----------------
  9. local doorStatus = {
  10.     CLOSED = false,
  11.     OPEN = true
  12. }
  13.  
  14. local alarmStatus = {
  15.     OFF = false,
  16.     ON = true
  17. }
  18.  
  19.  
  20. function toggleDoors(status)
  21.     local doorSide = "right" -- Direction of door
  22.     if status == doorStatus.CLOSED then
  23.         rs.setOutput(doorSide, false)
  24.         print("Opening doors")
  25.     elseif status == doorStatus.OPEN then
  26.         rs.setOutput(doorSide, true)
  27.         print("Closing doors")
  28.     end
  29. end
  30.  
  31. function toggleAlarm(status)
  32.     local alarmSide = "back" -- Direction of alarm
  33.     if status == alarmStatus.OFF then
  34.         rs.setOutput(alarmSide, false)
  35.         print("Alarm Off")
  36.     elseif status == alarmStatus.ON then
  37.         rs.setOutput(alarmSide, true)
  38.         print("Alarm on")
  39.     end
  40. end
  41.  
  42. -- Arms or disarms alarm
  43. function alarmArm(activate)
  44.     local intrusionDetection = "left" --Direction of sensor
  45.     if activate == true then
  46.         if rs.getInput(intrusionDetection) == true then
  47.             toggleAlarm(alarmStatus.ON)
  48.         else
  49.             toggleAlarm(alarmStatus.OFF)
  50.         end
  51.     end
  52. end
  53. --[[
  54.     Initialise monitors
  55.         - monitor_06  <- Inside monitor
  56.         - monitor_04  <- Outside monitor
  57. ]]
  58. local inMonitor = peripheral.wrap("monitor_6")
  59. local outMonitor = peripheral.wrap("monitor_4")
  60.  
  61. inMonitor.setTextScale(0.5)
  62. outMonitor.setTextScale(0.5)
  63.  
  64. -- GUI
  65. local labels = {
  66.     "1", "2", "3",
  67.     "4", "5", "6",
  68.     "7", "8", "9",
  69.     "X", "0", ">"
  70. }
  71.  
  72. local outBorder = {
  73.     "+----------------------------------+",
  74.     "|                                  |",
  75.     "|                                  |",
  76.     "|                                  |",
  77.     "|                                  |",
  78.     "|                                  |",
  79.     "|                                  |",
  80.     "|                                  |",
  81.     "|                                  |",
  82.     "+----------------------------------+"
  83. }
  84.  
  85. -- function clearMonitor(monitor)
  86.     -- monitor.clear()
  87.     -- print("Monitor cleared")
  88. -- end
  89.  
  90. -- for i = 1, 10, 1 do
  91.     -- monitor.setCursorPos(1, i)
  92.     -- monitor.write(outBorder)
  93. -- end
  94. -- Main loop
  95. --while true do
  96.    
  97. --end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement