----------------------------------
-- Elite's DE Energy Reader --
--Motified from Hypnotized's code--
-----------------------------------
--Send everything to the Monitor--
mon = peripheral.wrap("right")
p = peripheral.wrap("draconic_rf_storage_10")
term.redirect(mon)
-- Set Refresh Rate
local t = {}
local refreshRate = 1
local prevEnergyStored = 0
local diff = 0
local function comma_value(amount)
local formatted = amount
local k = 0
while true do
formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
if (k == 0) then
break
end
end
return formatted
end
--TitleBar
function titleBar()
term.setCursorPos(1,1)
term.setBackgroundColor(colors.blue)
term.setTextColor(colors.lightGray)
term.clearLine()
term.setCursorPos(2,1)
print("Draconic Evo Energy Monitor")
end
while true do
local energyStored = p.getEnergyStored()
local maxEnergyStored = p.getMaxEnergyStored()
local percent = energyStored/maxEnergyStored*100
diff = (energyStored - prevEnergyStored)/(refreshRate*20)
t[0] = energyStored
t[1] = maxEnergyStored
t[2] = percent
t[3] = diff
local msg = textutils.serialize(t)
rednet.open("bottom")
rednet.broadcast(msg)
--Print Stuff to the screen
term.clear()
titleBar()
term.setBackgroundColor(colors.black)
term.setCursorPos(1,3)
term.setTextColor(colors.red)
print(" Max Energy: "..comma_value(maxEnergyStored))
term.setCursorPos(1,5)
term.setTextColor(colors.green)
print("Current Energy: "..comma_value(energyStored).." ")
term.setCursorPos(1,6)
print(" ("..percent.."%)")
print()
if (diff > 0) then
print(" Avg. RF/t: +"..comma_value(diff))
else
term.setTextColor(colors.red)
print(" Avg. RF/t: "..comma_value(diff))
end
prevEnergyStored = energyStored
os.sleep(refreshRate)
end
Comments