Page 1 of 1

Electric Network data

Posted: Fri Jan 19, 2018 5:35 am
by Reika
From what I can tell, there is no way to access this; you can get the LuaFlowStatistics, but that only seems to have data about total energy transfer since...forever(?), not anything useful like current generation by category or satisfaction fraction.

Re: Electric Network data

Posted: Fri Jan 28, 2022 4:46 am
by manuell
Motivation:
I would like to make a mod that provides circuit signals for the status of the electrical network.
Basically I would like to have access to the electric network info panels data:
  • satisfaction, both values
  • production, both values
  • accumulator charge, both values
In conjunction with the mod Power Overload this enables management of charge and discharge of accumulators.


what is currently possible:
Read LuaFlowStatistics and sum up the input and output of the electrical network. This gives no hint if the network has reserves.

I searched in the forum and found also these requests: Summary

Code: Select all

local stats = electricPole.network.stats;
stats.satisfactionCurrent
stats.satisfactionNeeded
stats.productionCurrent
stats.productionPossible
stats.accumulatorChargeCurrent
stats.accumulatorChargePossible

-- a request I found in the other discussions
local assembler = ...
assembler.powerState -- the energy bar when you hover over an assembler, inserter ..
-- could be also
assembler.energyCurrent
assembler.energyNeeded -- to skip the conversion to percent

-- another request was it to get access to all electric networks eg.
for networkId, stats in pairs(player.force.electricNetworks) do
-- the same network stats as above

-- event for split / join electric network (especially when rewiring)
script.on_event(defines.events.wire_joined, function(event)
event.fromEntity
event.toEntity
event.wireType
end)

script.on_event(defines.events.wire_cut, function(event)
event.fromEntity
event.toEntity
event.wireType
end)

-- for power pole entities, access to the connected circuit networks
pole.greenCircuit
pole.redCircuit
It would be awesome if we had access to better electrical network statistics data.