Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component")
- local sides = require("sides")
- local powerbox = component.inventory_controller
- local battery1 = {}
- local battery2 = {}
- local battery3 = {}
- local battery4 = {}
- local battery5 = {}
- local battery6 = {}
- local battery7 = {}
- local battery8 = {}
- local battery9 = {}
- local battery10 = {}
- local battery11 = {}
- local battery12 = {}
- local battery13 = {}
- local battery14 = {}
- local battery15 = {}
- local battery16 = {}
- local gpu = component.gpu
- local w, h = gpu.getResolution()
- local refreshRate = 5
- local EUtotal = 0
- local EUMax = 0
- local EUprevious = 0
- local EUchange = 1
- gpu.fill(1, 1, w, h, " ")
- gpu.set(1, 1, " Doomascus Power Stats ")
- local function round(num) return math.floor(num+.5) end
- local function pollBatteries()
- battery1 = powerbox.getStackInSlot(sides.bottom, 1)
- battery2 = powerbox.getStackInSlot(sides.bottom, 2)
- battery3 = powerbox.getStackInSlot(sides.bottom, 3)
- battery4 = powerbox.getStackInSlot(sides.bottom, 4)
- battery5 = powerbox.getStackInSlot(sides.bottom, 5)
- battery6 = powerbox.getStackInSlot(sides.bottom, 6)
- battery7 = powerbox.getStackInSlot(sides.bottom, 7)
- battery8 = powerbox.getStackInSlot(sides.bottom, 8)
- battery9 = powerbox.getStackInSlot(sides.bottom, 9)
- battery10 = powerbox.getStackInSlot(sides.bottom, 10)
- battery11 = powerbox.getStackInSlot(sides.bottom, 11)
- battery12 = powerbox.getStackInSlot(sides.bottom, 12)
- battery13 = powerbox.getStackInSlot(sides.bottom, 13)
- battery14 = powerbox.getStackInSlot(sides.bottom, 14)
- battery15 = powerbox.getStackInSlot(sides.bottom, 15)
- battery16 = powerbox.getStackInSlot(sides.bottom, 16)
- end
- local function addEU()
- EUMax = 0
- EUtotal = 0
- if battery1 ~= nil then
- EUtotal = EUtotal + battery1.charge
- EUMax = EUMax + battery1.maxCharge
- end
- if battery2 ~= nil then
- EUtotal = EUtotal + battery2.charge
- EUMax = EUMax + battery2.maxCharge
- end
- if battery3 ~= nil then
- EUtotal = EUtotal + battery3.charge
- EUMax = EUMax + battery3.maxCharge
- end
- if battery4 ~= nil then
- EUtotal = EUtotal + battery4.charge
- EUMax = EUMax + battery4.maxCharge
- end
- if battery5 ~= nil then
- EUtotal = EUtotal + battery5.charge
- EUMax = EUMax + battery5.maxCharge
- end
- if battery6 ~= nil then
- EUtotal = EUtotal + battery6.charge
- EUMax = EUMax + battery6.maxCharge
- end
- if battery7 ~= nil then
- EUtotal = EUtotal + battery7.charge
- EUMax = EUMax + battery7.maxCharge
- end
- if battery8 ~= nil then
- EUtotal = EUtotal + battery8.charge
- EUMax = EUMax + battery8.maxCharge
- end
- if battery9 ~= nil then
- EUtotal = EUtotal + battery9.charge
- EUMax = EUMax + battery9.maxCharge
- end
- if battery10 ~= nil then
- EUtotal = EUtotal + battery10.charge
- EUMax = EUMax + battery10.maxCharge
- end
- if battery11 ~= nil then
- EUtotal = EUtotal + battery11.charge
- EUMax = EUMax + battery11.maxCharge
- end
- if battery12 ~= nil then
- EUtotal = EUtotal + battery12.charge
- EUMax = EUMax + battery12.maxCharge
- end
- if battery13 ~= nil then
- EUtotal = EUtotal + battery13.charge
- EUMax = EUMax + battery13.maxCharge
- end
- if battery14 ~= nil then
- EUtotal = EUtotal + battery14.charge
- EUMax = EUMax + battery14.maxCharge
- end
- if battery15 ~= nil then
- EUtotal = EUtotal + battery15.charge
- EUMax = EUMax + battery15.maxCharge
- end
- if battery16 ~= nil then
- EUtotal = EUtotal + battery16.charge
- EUMax = EUMax + battery16.maxCharge
- end
- if EUprevious > EUtotal then
- EUchange = 0
- else
- EUchange = 1
- end
- EUprevious = EUtotal
- end
- local function drawScreen()
- pollBatteries()
- addEU()
- gpu.fill(1, 2, w, h, " ")
- gpu.set(1, 2, "Stored: " .. EUtotal .. " EU")
- gpu.set(1, 3, "Max: " .. EUMax .. " EU")
- gpu.set(1, 4, "Storage Percent: " .. tostring(round(((EUtotal/EUMax)*100))) .. "%")
- if EUchange == 0 then
- gpu.set(1, 5, "Power Levels: !!SHORTAGE!!")
- else
- gpu.set(1, 5, "Power Levels: OPTIMAL.")
- end
- end
- drawScreen()
- while true do
- drawScreen()
- os.sleep(refreshRate)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement