Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- args = {...}
- alert = nil
- sender = nil
- notes = nil
- isDebugging = false
- function mouse_wrapper(minX, maxX, Y)
- event, button, xPos, yPos = os.pullEvent(mouse_click)
- if (xPos >= minX or xPos <= maxX and yPos == Y) then
- return true
- else
- return false
- end
- end
- function key_wrapper(keyYes)
- event, key = os.pullEvent(mouse_click)
- if key==keyYes then
- return true
- else
- return false
- end
- end
- function error_show()
- print("EMERGENCY ALERT SYSTEM")
- print("")
- print("Available event codes:")
- print("EAN, EAT, EVI, CDW, CEM, ADM, LAE, LEW,")
- print("NIC, HMW, SPW, SVS, TOR, BHW, CHW.")
- print("Available sender codes:")
- print("PEP, CIV, CDC, DOD.")
- print("See \"Specific Area Message Encoding\"")
- print("on Wikipedia for further information.")
- printError("Usage: eas")
- return
- end
- function openModems()
- for _, v in pairs(rs.getSides()) do
- if peripheral.getType(v) == "modem" then
- rednet.open(v)
- if isDebugging then print("[Debug mode] Attempted to open modem on side: "..v) end
- end
- end
- end
- function broadcastAlert(same_dec, sndr, message)
- term.clear()
- term.setCursorPos(1, 1)
- print("You are going to broadcast:")
- print("Alert type: "..same_dec)
- print("Description: "..message)
- print("[Broadcast (Y)] [Cancel]")
- if term.isColour() then
- if mouse_wrapper(1,14,4) then
- rednet.broadcast(same_dec.." has been issued by "..sndr.." with text \""..message.."\"", "easp")
- if isDebugging then print("[Debug mode] Attempted to broadcast EAS transmission") end
- print("Broadcasted successfully")
- else
- print("Cancelled")
- end
- else
- if key_wrapper("Y") then
- if isDebugging then print("[Debug mode] Attempted to broadcast EAS transmission") end
- rednet.broadcast(same_dec.." has been issued by "..sndr.." with text \""..message.."\"", "easp")
- print("Broadcasted successfully")
- else
- print("Cancelled")
- end
- end
- end
- function same_decode(code)
- local same_d = nil
- if code == "EAN" then
- same_d = "Emergency Action Notification"
- sender = "EAN Network"
- elseif code == "EAT" then
- same_d = "Emergency Action Termination"
- sender = "EAN Network"
- elseif code == "EVI" then
- same_d = "Evacuation Immediate"
- elseif code == "CDW" then
- same_d = "Civil Danger Warning"
- elseif code == "CEM" then
- same_d = "Civil Emergency Message"
- elseif code == "ADM" then
- same_d = "Administrative Message"
- elseif code == "LAE" then
- same_d = "Local Area Emergency"
- elseif code == "LEW" then
- same_d = "Law Enforcement Warning"
- elseif code == "NIC" then
- same_d = "National Information Center Statement"
- elseif code == "HMW" then
- same_d = "Hazardous Materials Warning"
- elseif code == "SPW" then
- same_d = "Shelter-In-Place Warning"
- elseif code == "SVS" then
- same_d = "Severe Weather Statement"
- elseif code == "TOR" then
- same_d = "Tornado Warning"
- elseif code == "BHW" then
- same_d = "Biological Hazard Warning"
- elseif code == "CHW" then
- same_d = "Chemical Hazard Warning"
- else
- error_show()
- end
- return same_d
- end
- function sender_decode(c)
- local s = nil
- if c == "PEP" then
- s == "Primary Entry Point System"
- elseif c == "CIV" then
- s == "Civil Authorities"
- elseif c == "CDC" then
- s == "Centers for Disease Control and Prevention"
- elseif c == "DOD" then
- s == "Department of Defense"
- elseif c == "EPA" then
- s == "Environmental Protection Agency"
- else
- error_show()
- end
- return s
- end
- openModems()
- term.clear()
- term.setCursorPos(1, 1)
- if args[1] == "-debug" then
- if term.isColour then
- print("[Debug mode] Running on Advanced PC.")
- else
- print("[Debug mode] Running on Standard PC.")
- end
- isDebugging = true
- end
- sleep(0.5)
- term.clear()
- term.setCursorPos(15, 1)
- print("EMERGENCY ALERT SYSTEM")
- print("")
- print("Available event codes:")
- print("EAN, EAT, EVI, CDW, CEM, ADM, LAE, LEW,")
- print("NIC, HMW, SPW, SVS, TOR, BHW, CHW.")
- print("See \"Specific Area Message Encoding\"")
- print("on Wikipedia for further information.")
- write("Enter sender code:")
- local inputs = read()
- if isDebugging then print("[Debug mode] Received Sender Code: "..inputs) end
- print("Received sender: "..sender_decode(inputs))
- sender = sender_decode(inputs)
- write("Enter event code: ")
- local inputc = read()
- if isDebugging then print("[Debug mode] Received Event Code: "..inputc) end
- print("Received type: ".. same_decode(inputc))
- alert = same_decode(inputc)
- write("Enter message: ")
- local inputm = read()
- print("Received text: "..inputm)
- notes = inputm
- broadcastAlert(alert, sender, notes)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement