Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local cells = peripheral.getNames()
- local totalEnergyStored = 0
- local maxCapacity = 0
- local totalEnergyCells = 0
- local lowEnergyCells = 0
- local highEnergyCells = 0
- function reset()
- totalEnergyStored = 0
- maxCapacity = 0
- totalEnergyCells = 0
- lowEnergyCells = 0
- highEnergyCells = 0
- end
- function comma(v)
- local s = string.format("%d", math.floor(v))
- local pos = string.len(s) % 3
- if pos == 0 then pos = 3 end
- return string.sub(s, 1, pos)
- .. string.gsub(string.sub(s, pos + 1), "(...)", ",%1")
- end
- function readEnergyCells()
- for i,j in ipairs(cells) do
- if peripheral.getType(j) == "cofh_thermalexpansion_energycell" then
- energyStored = peripheral.call(j, "getEnergyStored", "unknown")
- energyMax = peripheral.call(j, "getMaxEnergyStored", "unknown")
- if energyStored < 10000000 then
- lowEnergyCells = lowEnergyCells + 1
- elseif energyStored > 40000000 then
- highEnergyCells = highEnergyCells + 1
- end
- totalEnergyCells = totalEnergyCells + 1
- totalEnergyStored = totalEnergyStored + energyStored
- maxCapacity = maxCapacity + energyMax
- end
- end
- end
- function chargeEnergyCells()
- end
- function printEnergyCells()
- print("Total Number of Enery Cells: "..totalEnergyCells)
- print("Low Energy Cells: "..lowEnergyCells)
- print("Total Energy Stored: "..comma(totalEnergyStored))
- print("Maximum Capacity: "..comma(maxCapacity))
- end
- while true do
- readEnergyCells()
- printEnergyCells()
- if lowEnergyCells >= totalEnergyCells - 1 then
- redstone.setOutput("back", true)
- elseif highEnergyCells == totalEnergyCells then
- redstone.setOutput("back", false)
- end
- reset()
- sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement