[2.0.76] Enumerating all know electrical networks on a surface
Posted: Sun Mar 15, 2026 10:19 pm
Right now, I am using code similar to this:
to enumerate all known electric networks on a surface. This seems cumbersome. Is there a better way to do that? I was hoping for a LuaSurface#get_all_electrical_networks() or so but there seems to be nothing.
Code: Select all
local surface_index = 1
local known_networks = {}
for _, e in pairs (game.surfaces[surface_index].find_entities_filtered { type = 'electric-pole' }) do
known_networks[e.electric_network_id] = true
end
for id in pairs(known_networks) do
print(id)
end