Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local statusChannelID = 5
- -- Find Modem
- local modem = peripheral.find("modem", function(n, o) return o.isWireless() end)
- if modem == nil then
- error("Could not find a modem. Is one attached?")
- end
- -- Bind the Draconic RF Storage
- local decore = peripheral.find("draconic_rf_storage")
- if decore == nil then
- error("Could not Draconic RF Storage. Is one attached?")
- end
- function round(num, idp)
- local mult = 10^(idp or 0)
- return math.floor(num * mult + 0.5) / mult
- end
- local function prettyAmt(num)
- if num >= 1000000000000 then
- return (tostring(round(num/1000000000000, 2)) .. "T")
- elseif num >= 1000000000 then
- return (tostring(round(num/1000000000, 2)) .. "B")
- elseif num >= 1000000 then
- return (tostring(round(num/1000000, 2)) .. "M")
- elseif num >= 1000 then
- return (tostring(round(num/1000, 2)) .. "t")
- else
- return tostring(num)
- end
- end
- term.clear()
- term.setCursorPos(1,1)
- print("Draconic RF Storage Monitor...")
- print()
- print("DECore Stored: ")
- print()
- print("Press 'q' to quit.")
- print()
- local pollTimer = os.startTimer(0)
- local status = {}
- while true do
- local event, p1, p2, p3, p4 = os.pullEvent()
- if event == "key" then
- if p1 == 16 then -- 'q'
- term.setCursorPos(1, 6)
- return
- end
- elseif event == "timer" and p1 == pollTimer then
- -- Check the Solar charged energy cell to determine if the
- --local energyP = (decore.getEnergyStored() / decore.getMaxEnergyStored()) * 100
- --status["DECore Stored RF"] = math.floor(energyP) .. "%"
- local energyP = decore.getEnergyStored()
- status["DECore Stored RF"] = prettyAmt(energyP)
- term.setCursorPos(1,3)
- term.write("DECore Stored RF: " .. status["DECore Stored RF"] .. " ")
- if modem ~= nil then modem.transmit(statusChannelID, 0, textutils.serialize(status)) end
- pollTimer = os.startTimer(5)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement