Why does WireConnectionDefinition have fields source_wire_id and target_wire_id?

Place to post guides, observations, things related to modding that are not mods themselves.
Post Reply
thesixthroc
Inserter
Inserter
Posts: 24
Joined: Wed Apr 29, 2020 9:53 pm
Contact:

Why does WireConnectionDefinition have fields source_wire_id and target_wire_id?

Post by thesixthroc »

The API definition for WireConnectionDefinition states that the field wire should be "either defines.wire_type.red or defines.wire_type.green." IE, not copper.

But also listed are two fields source_wire_id and target_wire_id, and it seems to be stated that these are to specify the type of copper wire connection.

If wire cannot be used, what are these fields supposed to do?

https://lua-api.factorio.com/latest/Con ... Definition

User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 2248
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: Why does WireConnectionDefinition have fields source_wire_id and target_wire_id?

Post by boskid »

This looks like an issue with documentation because in case of a copper wire you have to specify a wire value equal to `defines.wire_type.copper` to make parser to look for the `source_wire_id` and `target_wire_id` fields. When a wire is `defines.wire_type.red` or `defines.wire_type.green` it will look for `source_circuit_id` and `target_circuit_id` instead.

thesixthroc
Inserter
Inserter
Posts: 24
Joined: Wed Apr 29, 2020 9:53 pm
Contact:

Re: Why does WireConnectionDefinition have fields source_wire_id and target_wire_id?

Post by thesixthroc »

Indeed. For the dev's information, I came across this inconsistency when the following error was obtained during a .connect_neighbour() call in my scenario:

"Expected source_wire_id for entities with more than one wire connection."

The parameters for .connect_neighbour() were taken as exactly those four parameters obtained by a call of .circuit_connected_entities on another entity — yet this call claims to only spit out red or green wires, not copper. Which entities in particular I do not know, but something unexpected is afoot. (EDIT: I think they were ghost entities.)

Post Reply

Return to “Modding discussion”