Advertisement
Guest User

Untitled

a guest
Apr 1st, 2015
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.36 KB | None | 0 0
  1. args = {...}
  2. alert = nil
  3. sender = nil
  4. notes = nil
  5. isDebugging = false
  6.  
  7. function mouse_wrapper(minX, maxX, Y)
  8. event, button, xPos, yPos = os.pullEvent(mouse_click)
  9. if (xPos >= minX or xPos <= maxX and yPos == Y) then
  10. return true
  11. else
  12. return false
  13. end
  14. end
  15.  
  16. function key_wrapper(keyYes)
  17. event, key = os.pullEvent(mouse_click)
  18. if key==keyYes then
  19. return true
  20. else
  21. return false
  22. end
  23. end
  24.  
  25. function error_show()
  26. print("EMERGENCY ALERT SYSTEM")
  27. print("")
  28. print("Available event codes:")
  29. print("EAN, EAT, EVI, CDW, CEM, ADM, LAE, LEW,")
  30. print("NIC, HMW, SPW, SVS, TOR, BHW, CHW.")
  31. print("Available sender codes:")
  32. print("PEP, CIV, CDC, DOD.")
  33. print("See \"Specific Area Message Encoding\"")
  34. print("on Wikipedia for further information.")
  35. printError("Usage: eas")
  36. return
  37. end
  38.  
  39. function openModems()
  40. for _, v in pairs(rs.getSides()) do
  41. if peripheral.getType(v) == "modem" then
  42. rednet.open(v)
  43. if isDebugging then print("[Debug mode] Attempted to open modem on side: "..v) end
  44. end
  45. end
  46. end
  47.  
  48. function broadcastAlert(same_dec, sndr, message)
  49. term.clear()
  50. term.setCursorPos(1, 1)
  51. print("You are going to broadcast:")
  52. print("Alert type: "..same_dec)
  53. print("Description: "..message)
  54. print("[Broadcast (Y)] [Cancel]")
  55. if term.isColour() then
  56. if mouse_wrapper(1,14,4) then
  57. rednet.broadcast(same_dec.." has been issued by "..sndr.." with text \""..message.."\"", "easp")
  58. if isDebugging then print("[Debug mode] Attempted to broadcast EAS transmission") end
  59. print("Broadcasted successfully")
  60. else
  61. print("Cancelled")
  62. end
  63. else
  64. if key_wrapper("Y") then
  65. if isDebugging then print("[Debug mode] Attempted to broadcast EAS transmission") end
  66. rednet.broadcast(same_dec.." has been issued by "..sndr.." with text \""..message.."\"", "easp")
  67. print("Broadcasted successfully")
  68. else
  69. print("Cancelled")
  70. end
  71. end
  72. end
  73.  
  74. function same_decode(code)
  75. local same_d = nil
  76. if code == "EAN" then
  77. same_d = "Emergency Action Notification"
  78. sender = "EAN Network"
  79. elseif code == "EAT" then
  80. same_d = "Emergency Action Termination"
  81. sender = "EAN Network"
  82. elseif code == "EVI" then
  83. same_d = "Evacuation Immediate"
  84. elseif code == "CDW" then
  85. same_d = "Civil Danger Warning"
  86. elseif code == "CEM" then
  87. same_d = "Civil Emergency Message"
  88. elseif code == "ADM" then
  89. same_d = "Administrative Message"
  90. elseif code == "LAE" then
  91. same_d = "Local Area Emergency"
  92. elseif code == "LEW" then
  93. same_d = "Law Enforcement Warning"
  94. elseif code == "NIC" then
  95. same_d = "National Information Center Statement"
  96. elseif code == "HMW" then
  97. same_d = "Hazardous Materials Warning"
  98. elseif code == "SPW" then
  99. same_d = "Shelter-In-Place Warning"
  100. elseif code == "SVS" then
  101. same_d = "Severe Weather Statement"
  102. elseif code == "TOR" then
  103. same_d = "Tornado Warning"
  104. elseif code == "BHW" then
  105. same_d = "Biological Hazard Warning"
  106. elseif code == "CHW" then
  107. same_d = "Chemical Hazard Warning"
  108. else
  109. error_show()
  110. end
  111. return same_d
  112. end
  113.  
  114. function sender_decode(c)
  115. local s = nil
  116. if c == "PEP" then
  117. s == "Primary Entry Point System"
  118. elseif c == "CIV" then
  119. s == "Civil Authorities"
  120. elseif c == "CDC" then
  121. s == "Centers for Disease Control and Prevention"
  122. elseif c == "DOD" then
  123. s == "Department of Defense"
  124. elseif c == "EPA" then
  125. s == "Environmental Protection Agency"
  126. else
  127. error_show()
  128. end
  129. return s
  130. end
  131.  
  132. openModems()
  133. term.clear()
  134. term.setCursorPos(1, 1)
  135. if args[1] == "-debug" then
  136. if term.isColour then
  137. print("[Debug mode] Running on Advanced PC.")
  138. else
  139. print("[Debug mode] Running on Standard PC.")
  140. end
  141. isDebugging = true
  142. end
  143. sleep(0.5)
  144. term.clear()
  145. term.setCursorPos(15, 1)
  146. print("EMERGENCY ALERT SYSTEM")
  147. print("")
  148. print("Available event codes:")
  149. print("EAN, EAT, EVI, CDW, CEM, ADM, LAE, LEW,")
  150. print("NIC, HMW, SPW, SVS, TOR, BHW, CHW.")
  151. print("See \"Specific Area Message Encoding\"")
  152. print("on Wikipedia for further information.")
  153. write("Enter sender code:")
  154. local inputs = read()
  155. if isDebugging then print("[Debug mode] Received Sender Code: "..inputs) end
  156. print("Received sender: "..sender_decode(inputs))
  157. sender = sender_decode(inputs)
  158. write("Enter event code: ")
  159. local inputc = read()
  160. if isDebugging then print("[Debug mode] Received Event Code: "..inputc) end
  161. print("Received type: ".. same_decode(inputc))
  162. alert = same_decode(inputc)
  163. write("Enter message: ")
  164. local inputm = read()
  165. print("Received text: "..inputm)
  166. notes = inputm
  167. broadcastAlert(alert, sender, notes)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement