local monitor = peripheral.wrap("top") local core = peripheral.wrap("draconic_rf_storage_0") monitor.setTextScale(0.5) monitor.setBackgroundColor(colors.black) monitor.setTextColor(colors.white) local BAR_WIDTH = 40 local BAR_Y = 5 local function formatRF(v) if v >= 1e12 then return string.format("%.2f T", v / 1e12) end if v >= 1e9 then return string.format("%.2f G", v / 1e9) end if v >= 1e6 then return string.format("%.2f M", v / 1e6) end if v >= 1e3 then return string.format("%.2f k", v / 1e3) end return tostring(v) end local function formatTime(seconds) if seconds == math.huge then return "∞" end local h = math.floor(seconds / 3600) local m = math.floor((seconds % 3600) / 60) local s = math.floor(seconds % 60) return string.format("%02d:%02d:%02d", h, m, s) end while true do monitor.clear() local energy = core.getEnergyStored() local maxEnergy = core.getMaxEnergyStored() local input = core.getLastInput and core.getLastInput() or 0 local output = core.getLastOutput and core.getLastOutput() or 0 local net = input - output local percent = energy / maxEnergy local filled = math.floor(percent * BAR_WIDTH) monitor.setCursorPos(2, 1) monitor.write("Draconic Energy Core") monitor.setCursorPos(2, BAR_Y) monitor.write("[") monitor.setCursorPos(3, BAR_Y) monitor.setBackgroundColor(colors.green) monitor.write(string.rep(" ", filled)) monitor.setBackgroundColor(colors.gray) monitor.write(string.rep(" ", BAR_WIDTH - filled)) monitor.setBackgroundColor(colors.black) monitor.write("]") monitor.setCursorPos(2, BAR_Y + 2) monitor.write("Stored: " .. formatRF(energy) .. " / " .. formatRF(maxEnergy)) monitor.setCursorPos(2, BAR_Y + 3) monitor.write(string.format("Charge: %.2f%%", percent * 100)) monitor.setCursorPos(2, BAR_Y + 4) monitor.write("Net RF/t: " .. formatRF(net)) monitor.setCursorPos(2, BAR_Y + 6) if net > 0 then monitor.write("Time to full: " .. formatTime((maxEnergy - energy) / net / 20)) elseif net < 0 then monitor.write("Time to empty: " .. formatTime(energy / math.abs(net) / 20)) else monitor.write("Time: Stable") end sleep(1) end