Finding separate electric networks

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
Post Reply
AngledLuffa
Fast Inserter
Fast Inserter
Posts: 187
Joined: Fri Jan 05, 2018 5:18 pm
Contact:

Finding separate electric networks

Post by AngledLuffa »

Is there a way to find separate electric networks on a map? Base game or a mod would both be fine. I ask because during a recent survey of my biggest base, I found that there were a few hundred solar panels not connected to the rest of the network. It's possible there are other clusters of panels or accumulators that aren't attached yet.

Thanks!

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Finding separate electric networks

Post by eradicator »

On the "maxi"-map you can enable showing connected power poles via the buttons on the right. Using the debug overlay (F4/F5/F6/F7) you can also enable "show-network-connected-entities" which will display the network number on every pole. If two poles have different numbers they're not on the same network. Though if two networks are connected via power switch they'll have different numbers.

I'm not aware of any mod that automatically shows this. Detecting it should be possible, but i'm not sure how a mod should communicate its findings to the user. Maybe map tags at the center of each network? That might work.

Edit: After some rummaging through the api i see no method to determine if two power poles are on the same network :/. Using .neighbour and a cache of all poles would work, i guess...
Last edited by eradicator on Mon Oct 22, 2018 7:55 pm, edited 3 times in total.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

AngledLuffa
Fast Inserter
Fast Inserter
Posts: 187
Joined: Fri Jan 05, 2018 5:18 pm
Contact:

Re: Finding separate electric networks

Post by AngledLuffa »

The debug overlay sounds like a good place to start, thanks!

Now I find myself wondering if such a mod could also find accumulators, panels, or other entities which are not connected to any network at all. I know about the blinking electric symbol when first installed, but I've been installing power by laying down bot blueprints and then forgetting about them, so if cliffs or water disrupted the blueprint there may be more unattached items.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Finding separate electric networks

Post by eradicator »

AngledLuffa wrote:
Mon Oct 22, 2018 7:34 pm
The debug overlay sounds like a good place to start, thanks!
See also the edit above. If networks are seperated by switches they won't have the same number. Just something to keep in mind.

Also finding unpowered entities is much easier:

Code: Select all

/c
for _,this in pairs(game.player.surface.find_entities_filtered{force=game.player.force}) do
  if (not this.is_connected_to_electric_network()) and this.electric_buffer_size then
    game.player.force.add_chart_tag(this.surface,{icon={type='virtual',name='signal-red'},position=this.position,orientation=0.2})
    end
  end
This will add a red square map icon on every unconnected entity. Be careful to not save the game after using this, or you will have to manually remove all the icons, which could be quite exhausting. Also if your map is very large the command might take a few seconds to run.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2903
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Finding separate electric networks

Post by darkfrei »

eradicator wrote:
Mon Oct 22, 2018 7:52 pm
This will add a red square map icon on every unconnected entity. Be careful to not save the game after using this, or you will have to manually remove all the icons, which could be quite exhausting. Also if your map is very large the command might take a few seconds to run.
can we find all chart tags with icon {type='virtual',name='signal-red'}?

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Finding separate electric networks

Post by eradicator »

darkfrei wrote:
Mon Oct 22, 2018 8:25 pm
eradicator wrote:
Mon Oct 22, 2018 7:52 pm
This will add a red square map icon on every unconnected entity. Be careful to not save the game after using this, or you will have to manually remove all the icons, which could be quite exhausting. Also if your map is very large the command might take a few seconds to run.
can we find all chart tags with icon {type='virtual',name='signal-red'}?
Theoretically? Sure. You can write that if you want.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

AngledLuffa
Fast Inserter
Fast Inserter
Posts: 187
Joined: Fri Jan 05, 2018 5:18 pm
Contact:

Re: Finding separate electric networks

Post by AngledLuffa »

Thanks, the suggestion on how to find disconnected items was perfect. Fixed a few more solar panels whose block was placed slightly over water and didn't have a power pole.

Post Reply

Return to “Gameplay Help”