Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- DebiECDisplay - (c) monster010 - v1.0.0
- ----------------------------------
- ----- DONT CHANGE UNDER THIS -----
- ----------------------------------
- os.loadAPI('debiecdisplay/api/monster010')
- os.loadAPI('debiecdisplay/api/config')
- os.loadAPI('debiecdisplay/api/lbl')
- os.loadAPI('debiecdisplay/api/bars')
- local monsid
- local monitor = {}
- local ecells = {}
- function convEnergy(str)
- str = tostring(str)
- if string.len(str) >= 8 then
- str = string.sub(str, 0, 2).."M"
- elseif string.len(str) >= 7 then
- str = string.sub(str, 0, 1).."M"
- end
- return str
- end
- function connect()
- for k, v in pairs(peripheral.getNames()) do
- if peripheral.getType(v) == "tile_thermalexpansion_cell_resonant_name" or peripheral.getType(v) == "cofh_thermalexpansion_energycell" or peripheral.getType(v) == "powered_tile" or peripheral.getType(v) == "tile_thermalexpansion_cell_hardened_name" or peripheral.getType(v) == "tile_blockcapacitorbank_name" or peripheral.getType(v) == "tile_thermalexpansion_cell_basic_name" or peripheral.getType(v) == "tile_thermalexpansion_cell_reinforced_name" or peripheral.getType(v) == "Induktionsmatrix" then
- local conn = peripheral.wrap(v)
- ecells[k] = {}
- ecells[k]['conn'] = conn
- ecells[k]['energy'] = conn.getEnergyStored()
- ecells[k]['max'] = conn.getMaxEnergyStored()
- elseif peripheral.getType(v) == "monitor" then
- monsid = tostring(v)
- end
- end
- end
- function refreshECells()
- local mtimer = os.startTimer(1)
- while true do
- local event, args = os.pullEvent()
- if event == "timer" and args == mtimer then
- for k, v in pairs(ecells) do
- v['energy'] = v['conn'].getEnergyStored()
- v['max'] = v['conn'].getMaxEnergyStored()
- bars.set("bar_"..k, "cur", monster010.round(v['max']-v['energy'])-1)
- lbl.set("lbl1_"..k, "stxt", convEnergy(v['energy']))
- end
- bars.screen()
- lbl.screen()
- break
- end
- end
- end
- function setup()
- local mx, my = monitor.getSize()
- local an, bx, lx, ly, llx = 0, 0, mx / 2, 1, 0
- for k, v in pairs(ecells) do
- an = an + 1
- bx = bx + 2
- ly = ly + 2
- llx = llx + 2
- bars.add("bar_"..k, "ver", v['max'], monster010.round(v['max']-v['energy'])-1, bx, 3, 1, my - 4, colors.gray, colors.green)
- if ly > my - 2 then
- ly = 3
- lx = lx + 11
- end
- lbl.add("lbl1_"..k, "Z."..an, lx, ly, convEnergy(v['energy']))
- lbl.add("lbl2_"..k, tostring(an), llx, my-1)
- end
- bars.screen()
- lbl.screen()
- end
- function launchRestart()
- while true do
- local event, args = os.pullEvent("key")
- if args == 19 then
- os.reboot()
- end
- end
- end
- connect()
- monster010.construct(monsid, "Energy")
- monster010.startUp()
- monster010.heading()
- monitor = monster010.getMonitor()
- bars.construct(monitor)
- lbl.construct(monitor)
- setup()
- monster010.startUpDone()
- while true do
- parallel.waitForAny(refreshECells, launchRestart)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement