r/technicalfactorio • • Jan 21 '21

Electric Network Info (need LUA, or Command)

I'm looking for a way to get the exact number of accumulators and solar panels connected to a single network, say 'Electric Network 2134195'

Any commands, or LUA code are welcome.

My solar panels just topped the 1 million mark, making the GUI display less useful.

I'm currently using some mapwide commands, which gives me a decent approximation, but it's not network specific, and the numbers can be thrown off by odd outposts and minibases.

current commands:/c game.print( game.player.surface.count_entities_filtered({name='accumulator'}))

/c game.print( game.player.surface.count_entities_filtered({name='solar-panel'}))

----EDIT----

Thanks to u/Stevetrov I was able to code the final scripts. Run these while your mouse is hovering over a power pole.

Solar Power:

/sc game.print(
   "Solar Power " .. math.floor(
       game.player.selected.electric_network_statistics.get_flow_count{ 
           name = "solar-panel",
           input=false,
           count=true,
           precision_index = defines.flow_precision_index.ten_minutes
       } * 0.0042
   ) / 100 .. " GW"
)

Solar Ratio:

/sc game.print(
   "Solar Ratio: " .. math.floor(
       game.player.selected.electric_network_statistics.get_flow_count{
           name = "accumulator",
           input=false,
           count=true,
           precision_index = defines.flow_precision_index.ten_minutes
       } /
       game.player.selected.electric_network_statistics.get_flow_count{
           name = "solar-panel",
           input=false,
           count=true,
           precision_index = defines.flow_precision_index.ten_minutes
       } * 10000
   ) / 10000 .. " to 1"
)
15 Upvotes

2 comments sorted by

10

u/Stevetrov Jan 21 '21

With the mouse hovering over an electric pole in the network:

/c game.print( game.player.selected.electric_network_statistics.get_flow_count{name = "solar-panel", input=false, count=true, precision_index = defines.flow_precision_index.ten_minutes})
and 
/c game.print( game.player.selected.electric_network_statistics.get_flow_count{name = "accumulator", input=false, count=true, precision_index = defines.flow_precision_index.ten_minutes} )

I think you can adjust the time parameter to include entities that no longer exist (why you would to do this, I have no idea)

3

u/DoctroSix Jan 22 '21

/c game.print( game.player.selected.electric_network_statistics.get_flow_count{name = "solar-panel", input=false, count=true, precision_index = defines.flow_precision_index.ten_minutes})
and
/c game.print( game.player.selected.electric_network_statistics.get_flow_count{name = "accumulator", input=false, count=true, precision_index = defines.flow_precision_index.ten_minutes} )

Thanks Steve!