Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("top")
- rednet.host("ECC","ECM2")
- local monitor = peripheral.wrap("left")
- monitor.setTextScale(0.5)
- local deltax = 0
- local deltaxo = 0
- local allCurEnergy = 0
- local allMaxEnergy = 0
- function newline()
- local posX, pos = monitor.getCursorPos()
- monitor.setCursorPos(1,pos + 1)
- end
- function realMaxEnergy(...)
- local args = ...
- if args == "Elite Energy Cube" then
- return 12800000
- elseif args == "Advanced Energy Cube" then
- return 3200000
- elseif args == "Ultimate Energy Cube" then
- return 52000000
- elseif args == "TE Energy Cell" then
- return
- else
- return 10
- end
- end
- function headline()
- term.clear()
- term.setCursorPos(1,1)
- monitor.clear()
- monitor.setCursorPos(1,1)
- print[[
- Energy Control Monitor
- ]]
- monitor.setTextColor(colors.red)
- monitor.write("==========================")
- newline()
- monitor.write("= Energy Control Monitor =")
- newline()
- monitor.write("==========================")
- newline()
- end
- function printCubeType(...)
- local EC_data = ...
- for i = 1, #EC_data,1 do
- local curEnergy = EC_data[i][1]
- local maxEnergy = EC_data[i][2]
- if maxEnergy and curEnergy then
- local name = EC_data[i][3]
- local percentage = (curEnergy / maxEnergy) * 100
- if not EC_data[3] == "TE Energy Cell" then
- maxEnergy = realMaxEnergy(name)
- end
- curEnergy = (percentage / 100) * maxEnergy
- percentage = math.ceil(percentage)
- print(name..": "..tostring(percentage).."% " ..tostring(maxEnergy / 1000000).." MRF / "..tostring(curEnergy / 1000000).." MRF")
- print(" ")
- monitor.setTextColor(colors.white)
- monitor.write(name..": "..tostring(percentage).."% "..tostring(maxEnergy/1000000).." MRF "..tostring(curEnergy/1000000).." MRF")
- newline()
- allCurEnergy = allCurEnergy + curEnergy
- allMaxEnergy = allMaxEnergy + maxEnergy
- end
- end
- end
- while true do
- rednet.broadcast("request_EC_data","ECC")
- local time = os.clock() + 1
- local advCubes = {}
- local elCubes = {}
- local ultCubes = {}
- local unknownCubes = {}
- while time > os.clock() do
- local SID, MES, PROT = rednet.receive("ECC",1)
- if MES then
- if MES[3] == "Advanced Energy Cube" then
- table.insert(advCubes,(#advCubes + 1),MES)
- elseif MES[3] == "Elite Energy Cube" then
- table.insert(elCubes,(#elCubes + 1),MES)
- elseif MES[3] == "Ultimate Energy Cube" then
- table.insert(ultCubes,(#ultCubes + 1),MES)
- else
- table.insert(unknownCubes,(#ultCubes + 1),MES)
- end
- end
- end
- headline()
- printCubeType(advCubes)
- printCubeType(elCubes)
- printCubeType(ultCubes)
- printCubeType(unknownCubes)
- local postFix = " RF"
- local ACEA = allCurEnergy
- if allCurEnergy > 1000000000000 then
- allCurEnergy = allCurEnergy / 1000000000000
- postFix = " TerraRF"
- elseif allCurEnergy > 1000000000 then
- allCurEnergy = allCurEnergy / 1000000000
- postFix = " GigaRF"
- elseif allCurEnergy / 1000000 then
- allCurEnergy = allCurEnergy / 1000000
- postFix = " MegaRF"
- elseif allCurEnergy > 1000 then
- allCurEnergy = allCurEnergy / 1000
- postFix = " KiloRF"
- end
- postFix2 = " RF"
- AMEA = allMaxEnergy
- if allMaxEnergy < 10000000 then
- allMaxEnergy = allMaxEnergy / 1000000
- postFix2 = " MegaRF"
- elseif allMaxEnergy < 1000 then
- allMaxEnergy = allMaxEnergy / 1000
- postFix2 = " KiloRF"
- elseif allMaxEnergy > 1000000000 then
- allMaxEnergy = allMaxEnergy / 1000000000
- postFix2 = " GigaRF"
- end
- monitor.setTextColor(colors.red)
- newline()
- local x = string.sub(tostring(allCurEnergy),1,5)
- print("Current overall Energy Amount:")
- print(x..postFix.." ~ "..((ACEA - deltaxo)/1000).." KiloRF".."/sec")
- monitor.write("Current overall Energy Amount:")
- newline()
- -- monitor.write(x..postFix)
- monitor.write(x..postFix.." ~ "..((ACEA - deltaxo)/1000).." KiloRF".."/sec")
- newline()
- newline()
- local EA = ACEA - deltaxo
- if EA < 0 then
- local secs = ACEA / EA
- monitor.write("Approximately depleted in "..(secs * -1).. " Seconds!")
- elseif EA == 0 then
- monitor.write("Energylevel stable!")
- else
- local diff = ACEA - AMEA
- local secs = diff / EA
- monitor.write("Approximately full in "..secs.." Seconds!")
- end
- deltax = tonumber(x)
- deltaxo = tonumber(ACEA)
- newline()
- x = string.sub(tostring(allMaxEnergy),1,5)
- monitor.write("Maximum overall Capacity:")
- newline()
- monitor.write(x..postFix2)
- newline()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement