[1.0.0] script can't connect power-switch to pole with copper wire
Posted: Sat Aug 22, 2020 4:59 pm
I think connecting power-switch with electric-pole with copper-wire via scripting is not possible.
Here is some snippet for quick chat command (use it when player is on empty ground with some space)
Then it will say that "Only red or green cables can be accepted here."
Error is coming from "wire" key in input table of connect_neighbour() method.
I don't know it is right to use target_circuit_id here.
I couldn't find target_wire_id or similar thing in API website.
something like this.
And connect_neighbour(LuaEntity) are also not possible. It seems it is used for connecting between poles.
It throws error,
"Target entity is not electric pole: cannot connect copper wire."
So I couldn't find any scripting way to connect power-switch with electric pole with copper wires.
Here is some snippet for quick chat command (use it when player is on empty ground with some space)
Code: Select all
/silent-command
local p = game.player local pos = p.surface.find_non_colliding_position( 'rocket-silo', game.player.position, 20, 0.5, true )
if not pos then pos = p.position end
local powerswitch = p.surface.create_entity{name = 'power-switch', force = p.force, position = {pos.x,pos.y}}
local pole1 = p.surface.create_entity{name = 'medium-electric-pole', force = p.force, position = {pos.x-1,pos.y}}
local pole2 = p.surface.create_entity{name = 'medium-electric-pole', force = p.force, position = {pos.x+2,pos.y}}
for _, v in pairs(pole1.neighbours.copper) do if v==pole2 then v.disconnect_neighbour(pole1) break end end
pole1.connect_neighbour{
wire = defines.wire_type.copper,
target_entity = powerswitch,
target_circuit_id = defines.wire_connection_id.power_switch_left
}
Error is coming from "wire" key in input table of connect_neighbour() method.
I don't know it is right to use target_circuit_id here.
I couldn't find target_wire_id or similar thing in API website.
Code: Select all
powerswitch.connect_neighbour{
wire = defines.wire_type.copper,
target_entity = pole1,
source_wire_id = defines.wire_connection_id.power_switch_left
}
Code: Select all
powerswitch.connect_neighbour(pole1)
--or--
pole1.connect_neighbour(powerswitch)
It throws error,
"Target entity is not electric pole: cannot connect copper wire."
So I couldn't find any scripting way to connect power-switch with electric pole with copper wires.