Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local confMainPort = 1000
- local confMyPort = 1003
- local confModemSide = "right"
- local cellData = {}
- if(not os.loadAPI("hydraApi")) then
- error("Could not load hydraApi")
- end
- local modem = peripheral.wrap(confModemSide)
- local cells = hydraApi.getAllEnergyCells()
- if(modem == nil) then
- print("No modem found")
- end
- while true do
- local totalEnergy = 0
- local totalMaxEnergy = 0
- for k,cell in pairs(cells) do
- totalEnergy = totalEnergy + cell.getEnergyStored()
- totalMaxEnergy = totalMaxEnergy + cell.getMaxEnergyStored()
- end
- cellData["totalEnergy"] = totalEnergy
- cellData["totalMaxEnergy"] = totalMaxEnergy
- cellData["fraction"] = totalEnergy / totalMaxEnergy
- hydraApi.printTable(cellData)
- if(modem ~= nil) then
- modem.transmit(confMainPort, confMyPort, cellData)
- end
- os.sleep(2)
- end
Advertisement
Add Comment
Please, Sign In to add comment