Home

LuaWireConnector

A wire connector of a given entity. Allows to find wires, add or remove wires and do some basic operations specific to those connectors.

Attributes

owner

The entity this wire connector belongs to. May return entity ghost instead if this wire connector belongs to inner entity.

wire_type

The type of wires that can be connected to this connector.

wire_connector_id

Identifier of this connector in the entity this connector belongs to.

is_ghost

If this connector is owned by an entity inside of a ghost. If any of 2 ends of a wire attaches to a ghost connector, then a wire is considered to be a ghost.

connection_count

Amount of wires going out of this connector. It includes all wires (ghost wires and real wires).

connections

All wire connectors this connector is connected to. It includes all wires (ghost wires and real wires).

real_connection_count

Amount of real wires going out of this connector. It only includes wires for which both wire connectors are real (not ghosts).

real_connections

All wire connectors this connector is connected to with real wires. It only includes wires that are between two non-ghost entities.

network_id

Index of a CircuitNetwork or ElectricSubNetwork which is going through this wire connector. Returns 0 if there is no network associated with this wire connector right now. CircuitNetwork indexes are independent of indexes of ElectricSubNetwork so they may collide with each other.

valid

Is this object valid? This Lua object holds a reference to an object within the game engine. It is possible that the game-engine object is removed whilst a mod still holds the corresponding Lua object. If that happens, the object becomes invalid, i.e. this attribute will be false. Mods are advised to check for object validity if any change to the game state might have occurred between the creation of the Lua object and its access.

object_name

The class name of this object. Available even when valid is false. For LuaStruct objects it may also be suffixed with a dotted path to a member of the struct.

Methods

is_connected_to

LuaWireConnector.is_connected_to(target: LuaWireConnector, origin?: defines.wire_origin) -> boolean

Call As

wireConnector.is_connected_to(target, origin)

Call Convention

Checks if this connector has any wire going to the other connector.

Parameters

Returns

connect_to

LuaWireConnector.connect_to(target: LuaWireConnector, reach_check?: boolean, origin?: defines.wire_origin) -> boolean

Call As

wireConnector.connect_to(target, true)

Call Convention

Connects this connector to other wire connector.

Parameters

Returns

disconnect_from

LuaWireConnector.disconnect_from(target: LuaWireConnector, origin?: defines.wire_origin) -> boolean

Call As

wireConnector.disconnect_from(target, origin)

Call Convention

Disconnects this connector from other wire connector.

Parameters

Returns

disconnect_all

LuaWireConnector.disconnect_all(origin?: defines.wire_origin) -> boolean

Call As

wireConnector.disconnect_all()

Call Convention

Removes all wires going out of this wire connector.

Parameters

Returns

can_wire_reach

LuaWireConnector.can_wire_reach(other_connector: LuaWireConnector | LuaEntity) -> boolean

Call As

wireConnector.can_wire_reach(other_connector)

Call Convention

Checks if a wire can reach from this connector to the other connector.

Parameters

Returns

have_common_neighbour

LuaWireConnector.have_common_neighbour(other_connector: LuaWireConnector, ignore_ghost_neighbours?: boolean) -> boolean

Call As

wireConnector.have_common_neighbour(other_connector, true)

Call Convention

Checks if this and other wire connector have a common neighbour.

Parameters

Returns