can you let the power poles automatically connect to the power poles of the transformer?
you'd just need to set auto_connect_up_to_n_wires to >0, decrease max wire distance and on built disconnect the poles of the transformer from poles with the name of the input pole and vice versa
legacy code (doesn't work anymore, but you get the idea. new method is via get_wire_connector i guess)
local target_pole = create{name = "trafo-connection".."_tar_"..entity.direction%8, position = tarconpos, force = entity.force}
local source_pole = create{name = "trafo-connection".."_src_"..entity.direction%8, position = srcconpos, force = entity.force}
for key, neighbour in pairs(target_pole.neighbours.copper) do
.... if string.sub(neighbour.name,1,20) == "trafo-connection_src" then
........ target_pole.disconnect_neighbour(neighbour)
.... end
end
for key, neighbour in pairs(source_pole.neighbours.copper) do
.... if string.sub(neighbour.name,1,20) == "trafo-connection_tar" then
........ source_pole.disconnect_neighbour(neighbour)
.... end
end