Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local monitor = peripheral.find("monitor")
- local reactor = peripheral.find("BigReactors-Reactor")
- local core = peripheral.find("draconic_rf_storage")
- local rodSize = 4
- function clear()
- term.clear()
- term.setBackgroundColor(colors.black)
- term.setCursorPos(1,1)
- end
- function drawRods(sx, sy)
- local controlRods = reactor.getNumberOfControlRods()
- for i=1,controlRods do
- term.setCursorPos(1,1)
- local percent = reactor.getControlRodLevel(i-1)/100.0
- local h = math.floor(percent*rodSize)
- if percent == 1 then
- h = rodSize-1
- end
- local left = (rodSize-h)-1
- local x = sx+i*2
- local y = sy
- if i > 10 then
- y = y + rodSize+1
- x = sx + (i-10)*2
- end
- --write(tostring(i)..' '..tostring(h))
- --x,y,width,height
- paintutils.drawFilledBox(x, y, x, y+h, colours.green)
- if percent < 1 then
- paintutils.drawFilledBox(x, y+h, x, (y+h)+left, colours.red)
- end
- end
- term.setBackgroundColor(colours.black)
- end
- function drawHeader()
- local activeText = "Active"
- if not reactor.getActive() then
- activeText = "Disabled"
- end
- write("Reactor "..activeText.."\n")
- end
- function discordNotify(botName, message)
- local postData = "{ \"username\" : \""..botName.."\", \"content\" : \""..message.."\"}"
- local headers = {
- ["Content-Type"] = "application/json"
- }
- write(postData)
- -- Make a HTTP request
- local request,err = http.post("https://discordapp.com/api/webhooks/696901545643606046/Ki7Un8TIliV9qpMNtOaWdevL_z1YcRYw-kpZsVo18TvueOqI3UesNowY2b5ZlZhYq4Zj", postData, headers)
- if not request then error(err) end
- request.close()
- end
- function notifyStatus(fuelPercent)
- local activeText = "Active"
- if not reactor.getActive() then
- activeText = "Disabled"
- end
- energyStored = core.getEnergyStored()
- energyMax = core.getMaxEnergyStored()
- energyTransfer = core.getTransferPerTick()
- energyPercent = math.floor((energyStored*1.0/energyMax)*100.0)
- --Reactor
- info = "#Current Reactor Info\\n==================\\n\\n"
- info = info.."Status: "..activeText.."\\n"
- info = info.."Fuel: "..reactor.getFuelAmount().." mb "..fuelPercent.."%\\n"
- info = info.."Energy last Tick: "..reactor.getEnergyProducedLastTick().." RF\\n\\n"
- --Core
- if energyStored < 1000 then
- --Nothing
- elseif energyStored < 1000000 then
- energyStored = tostring(round((energyStored/1000),1)).."K"
- elseif energyStored < 1000000000 then
- energyStored = tostring(round((energyStored/1000000),1)).."M"
- elseif energyStored < 1000000000000 then
- energyStored = tostring(round((energyStored/1000000000),1)).."G"
- elseif energyStored < 1000000000000000 then
- energyStored = tostring(round((energyStored/1000000000000),1)).."T"
- elseif energyStored < 1000000000000000000 then
- energyStored = tostring(round((energyStored/1000000000000000),1)).."P"
- elseif energyStored < 1000000000000000000000 then
- energyStored = tostring(round((energyStored/1000000000000000000),1)).."E"
- end
- info = info.."#Core Info\\n==================\\n\\n"
- info = info.."Energy stored: "..energyStored.." RF "..energyPercent.."%\\n"
- info = info.."Current energy transfer: "..energyTransfer.." RF/t"
- if fuelPercent < 10 then
- info = info.."\\n\\nAlert: Fuel bellow 10%!"
- end
- discordNotify("Base Report", "```md\\n"..info.."```")
- end
- term.redirect(monitor)
- monitor.setTextScale(0.5)
- local updates = 0
- local screenUpdateEvery = 10
- local notifySent = false
- while true do
- if updates >= screenUpdateEvery then
- clear()
- drawHeader()
- drawRods(1, 4)
- updates = 0
- end
- local time = textutils.formatTime(os.time("local"), true)
- local fuelPercent = math.floor((reactor.getFuelAmount()*1.0/reactor.getFuelAmountMax())*100.0)
- --Send reactor status twice a day
- if not notifySent and (time == "17:00" or time == "10:00") then
- notifySent = true
- notifyStatus(fuelPercent)
- end
- --Prevent multiple notify per hour
- if notifySent and (time == "18:00" or time == "11:00") then
- notifySent = false
- end
- --notifyReactorStatus(fuelPercent)
- sleep(1)
- updates = updates + 1
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement