Page 1 of 1
[Solved] Find unpowered roboports
Posted: Thu Jun 25, 2026 3:31 pm
by xoft
I'd like to ask the smart people here about how to solve an issue I am currently stumped on:
I've been placing a regular electric grid with roboports all over Vulcanus. However, due to the terrain, some roboports ended up not connected to the electric network. With the grid having 2500+ roboports, it is now difficult to manually find the ones not connected. Is there a simple way to do this? Can I search for an entity with a specific property? I'm okay with even a console command, if anyone can cook one up.
Thanks.
Map sample:

- 06-25-2026, 17-31-11.png (639.84 KiB) Viewed 256 times
Re: Find unpowered roboports
Posted: Thu Jun 25, 2026 3:42 pm
by berggen
Code: Select all
/c for _, p in pairs(game.surfaces) do game.print(p.name) for _, v in pairs(p.find_entities()) do if v.electric_buffer_size and not v.is_connected_to_electric_network() then v.order_deconstruction(game.player.force) end end end
(from
https://www.reddit.com/r/technicalfacto ... _entities/)
You could alternatively print the location of v for each or something

Re: Find unpowered roboports
Posted: Thu Jun 25, 2026 7:04 pm
by xoft
Thank you. I iterated that code into the following version. Instead of marking for deconstruction, it adds a map tag; it also finds roboports that are connected to isolated power grids, simply by searching for roboports with less than 50 % charge:
Code: Select all
/c
local surface = game.player.surface
local force = game.player.force
for _, roboport in pairs(surface.find_entities_filtered{type = "roboport"}) do
local maxEnergy = roboport.prototype.electric_energy_source_prototype.buffer_capacity
local chargeFraction = roboport.energy / maxEnergy
if (chargeFraction < 0.5) then
force.add_chart_tag(
surface,
{
position = roboport.position,
text = string.format(
"[UNPOWERED-ROBOPORT] %.0f%%",
chargeFraction * 100
)
}
)
end
end
To remove the map tags later on:
Code: Select all
/c
local surface = game.player.surface
local force = game.player.force
for _, tag in pairs(force.find_chart_tags(surface)) do
if (string.find(tag.text or "", "^%[UNPOWERED%-ROBOPORT%]")) then
tag.destroy()
end
end