Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component")
- local term = require("term")
- local redstone = component.redstone
- local screen = component.proxy("ce5b8829-90c2-4022-9c69-8f4d5783c70b")
- local gpu = component.proxy("7f0687d2-c629-4270-a8fb-c20d8d12d5b3")
- local modem = component.modem
- local sides = require("sides")
- local thread = require("thread")
- gpu.bind(screen.address)
- gpu.setResolution(13,3)
- gpu.fill(1,1,13,3,' ')
- local cubes = {}
- local persecond = 0
- modem.open(1)
- local send_off = true
- function secondcalc()
- os.sleep(5)
- while true do
- local probeone = 0
- local probetwo = 0
- for x = 1,#cubes do
- probeone = probeone + cubes[x].getEnergy()
- end
- os.sleep(1)
- for x= 1,#cubes do
- probetwo = probetwo + cubes[x].getEnergy()
- end
- local probe = probetwo-probeone
- persecond = probe
- end
- end
- local t = thread.create(secondcalc)
- function energy()
- while true do
- cubes = {}
- for address, name in component.list("cube", false) do
- table.insert(cubes, component.proxy(address))
- end
- local length = tonumber(#cubes)
- gpu.setForeground(0xFFFFFF)
- gpu.set(1,1,string.format("%d Cubes:", length))
- local max_energy = 0
- local total_energy = 0
- for x=1,length do
- max_energy = max_energy + cubes[x].getMaxEnergy()
- total_energy = total_energy + cubes[x].getEnergy()
- end
- local percent = total_energy/max_energy*100
- if percent > 90.0 and send_off == false then
- modem.broadcast(1, "off")
- send_off=true
- elseif percent < 50.0 and send_off == true then
- modem.broadcast(1,"on")
- send_off = false
- end
- if percent < 50.0 and percent > 20.0 then
- gpu.setForeground(0xFFB600)
- elseif percent < 20.0 then
- gpu.setForeground(0xCC2400)
- else
- gpu.setForeground(0x33B600)
- end
- gpu.fill(1,2,13,2,' ')
- if not(percent< 70.0 and percent > 68.99 ) then
- gpu.set(1,2,string.format('%.2f %%', percent))
- else
- gpu.set(1,2,"HEHE BOÄ")
- end
- if redstone.getInput()[3] == 15.0 then
- gpu.set(1,3,string.format('%.0f kRF/t', persecond/1000))
- else
- gpu.set(1,3,string.format('%.2f MRF', total_energy/1000000))
- end
- term.clear()
- term.write(string.format("Ze Energy:\n"))
- term.write(string.format('%.2f %%\n',percent))
- term.write(string.format('%.0f/%.0f RF\n',total_energy,max_energy))
- term.write(string.format('%.2f RF/t', persecond))
- os.sleep(0.1)
- end
- end
- while not(pcall(energy)) do
- gpu.fill(1,1,13,2,' ')
- gpu.setForeground(0xFF0000)
- gpu.set(1,1,"Not")
- gpu.set(1,2,"Monitoring")
- term.clear()
- term.write("Not Monitoring. Restart imminent")
- for x=1,5 do
- gpu.set(x,3,".")
- os.sleep(1)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement