Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- modem = peripheral.find("modem")
- mon = peripheral.find("monitor")
- mon.clear()
- ---Next Page---
- mon.setCursorPos(29,12)
- mon.setTextColor(colors.white)
- mon.write(">")
- ---General Title--
- mon.setCursorPos(8,1)
- mon.setTextColor(colors.purple)
- mon.write("Reactor Status")
- --Stats--
- mon.setCursorPos(1,3)
- mon.setTextColor(colors.lightBlue)
- mon.write("Reactor Levels")
- modem.open(3)
- modem.open(4)
- modem.open(5)
- modem.open(6)
- modem.open(50)
- function handleModemMessages()
- while true do
- local event, _, channel, _, message = os.pullEvent("modem_message")
- if event == "modem_message" then
- if channel == 3 then
- mon.setCursorPos(3,5)
- mon.clearLine()
- local success, decoded = pcall(textutils.unserializeJSON, message)
- if success and decoded.command == "Coolant" and decoded.value then
- local value = tonumber(decoded.value)
- if value <= 30 then
- mon.setTextColor(colors.red) -- Critical (0-30)
- modem.transmit(50, 50, CoolantCritical)
- print("Message Sent to Speaker")
- elseif value <= 50 then
- mon.setTextColor(colors.orange) -- Low (30-50)
- elseif value <= 80 then
- mon.setTextColor(colors.yellow) -- Medium (50-80)
- else
- mon.setTextColor(colors.green) -- High (80-100)
- end
- mon.write("Coolant " .. value .. "% (" ..
- (value <= 30 and "Critical" or (value <= 50 and "Low" or (value <= 80 and "Medium" or "High"))) .. ")")
- end
- elseif channel == 4 then
- mon.setCursorPos(3,6)
- mon.clearLine()
- local success, decoded = pcall(textutils.unserializeJSON, message)
- if success and decoded.command == "Steam" and decoded.value then
- local value = tonumber(decoded.value)
- if value <= 30 then
- mon.setTextColor(colors.green) -- Critical (0-30)
- elseif value <= 50 then
- mon.setTextColor(colors.yellow) -- Low (30-50)
- elseif value <= 80 then
- mon.setTextColor(colors.orange) -- Medium (50-80)
- else
- mon.setTextColor(colors.red) -- High (80-100)
- end
- mon.write("Steam " .. value .. "% (" ..
- (value <= 30 and "Stable" or (value <= 50 and "Slight Increase" or (value <= 80 and "Dangerous" or "CRITICAL"))) .. ")")
- end
- elseif channel == 5 then
- mon.setCursorPos(3,7)
- mon.clearLine()
- local success, decoded = pcall(textutils.unserializeJSON, message)
- if success and decoded.command == "Fuel" and decoded.value then
- local value = tonumber(decoded.value)
- if value <= 30 then
- mon.setTextColor(colors.red) -- Critical (0-30)
- elseif value <= 50 then
- mon.setTextColor(colors.orange) -- Low (30-50)
- elseif value <= 80 then
- mon.setTextColor(colors.yellow) -- Medium (50-80)
- else
- mon.setTextColor(colors.green) -- High (80-100)
- end
- mon.write("Fuel " .. value .. "% (" ..
- (value <= 30 and "Critical" or (value <= 50 and "Low" or (value <= 80 and "Medium" or "High"))) .. ")")
- end
- elseif channel == 6 then
- mon.setCursorPos(3,8)
- mon.clearLine()
- local success, decoded = pcall(textutils.unserializeJSON, message)
- if success and decoded.command == "Waste" and decoded.value then
- local value = tonumber(decoded.value)
- if value <= 30 then
- mon.setTextColor(colors.green) -- Critical (0-30)
- elseif value <= 50 then
- mon.setTextColor(colors.yellow) -- Low (30-50)
- elseif value <= 80 then
- mon.setTextColor(colors.orange) -- Medium (50-80)
- else
- mon.setTextColor(colors.red) -- High (80-100)
- end
- mon.write("Nuclear Waste " .. value .. "% (" ..
- (value <= 30 and "Stable" or (value <= 50 and "Slight Increase" or (value <= 80 and "Dangerous" or "CRITICAL"))) .. ")")
- end
- end
- end
- end
- end
- function handleMonitorTouch()
- while true do
- local touchEvent, touchSide, x, y = os.pullEvent("monitor_touch")
- if touchEvent == "monitor_touch" and x == 29 and y == 12 then
- mon.clear()
- modem.close(3)
- modem.close(4)
- modem.close(5)
- modem.close(6)
- modem.close(50)
- shell.run("teste")
- return
- end
- end
- end
- parallel.waitForAll(handleModemMessages, handleMonitorTouch)
Add Comment
Please, Sign In to add comment