Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local c = require("component")
- local e = require("event")
- local t = require("term")
- local com = c.computer
- local m = c.modem
- local gpu = c.gpu
- local port = 123
- local w, h = gpu.getResolution()
- m.open(port)
- function msg(_, _,adr, _, _, message)
- if message == "off" then
- running = false
- event.ignore("modem_message", msg)
- m.send(adr,port,"Reactor control offline!")
- com.beep(1200,0.1)
- term.clear()
- os.exit()
- end
- end
- event.listen("modem_message", msg)
- running = true
- if component.isAvailable("br_reactor") then
- while running == true do
- t.clear()
- local r = c.br_reactor
- local power = r.getEnergyStored()
- local powerP = power / 10000000 * 100
- local fuel = r.getFuelAmount()
- local fuelMax = r.getFuelAmountMax()
- local fuelP = fuel / fuelMax *100
- local status = "status :"
- if powerP >= 90 then
- r.setActive(false)
- status = status.."Power levels OK!"
- elseif powerP <= 10 then
- r.setActive(true)
- status = status.."Power levels LOW"
- end
- if fuelP <= 5 then
- status = status.." | Fuel levels CRITICAL"
- elseif fuelP <= 20 then
- status = status.." | Fuel levels LOW"
- elseif fuelP > 20 then
- status = status.." | Fuel levels OK!"
- end
- gpu.set(w/2 - (string.len(status) /2 ),h/2,status)
- gpu.set(w/2 - 2, h/2+1, "Energy: "..math.floor(powerP).."%")
- gpu.set(w/2 - 2, h/2+2, "Fuel: "..math.floor(fuelP).."%")
- os.sleep(3)
- end
- else
- t.clear()
- local message = "[NO REACTOR CONNECTED]"
- gpu.set(w/2 - (string.len(message) /2 ),h/2,message)
- os.exit()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement