Unfortunately, they do not actually retain their wire information, which means they break their previous wiring.
I happen to have had to write this function for my own mod:
Code: Select all
local oldNeighbours = table.deepcopy(pole.neighbours);
pole.destroy()
pole = newPole
pole.disconnect_neighbour();
for connectType,neighbourGroup in pairs(oldNeighbours) do
if connectType == "copper" then
for k,v in pairs(neighbourGroup) do
pole.pole.connect_neighbour(v);
end
elseif connectType == "red" then
for k,v in pairs(neighbourGroup) do
pole.pole.connect_neighbour({wire = defines.wire_type.red, target_entity = v});
end
elseif connectType == "green" then
for k,v in pairs(neighbourGroup) do
pole.pole.connect_neighbour({wire = defines.wire_type.green, target_entity = v});
end
end
end
EDIT: You'll need to require util:
Code: Select all
require "util"