Factorio.com|Forums|Wiki|Mod Portal|API Docs

# Factorio Runtime Docs Version 2.0.77

# LuaWireConnector - Runtime Docs

## Class 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.

## Members

is_connected_to(target, origin?) | → boolean | Checks if this connector has any wire going to the other connector.
Checks if this connector has any wire going to the other connector.
connect_to(target, reach_check?, origin?) | → boolean | Connects this connector to other wire connector.
Connects this connector to other wire connector.
disconnect_from(target, origin?) | → boolean | Disconnects this connector from other wire connector.
Disconnects this connector from other wire connector.
disconnect_all(origin?) | → boolean | Removes all wires going out of this wire connector.
Removes all wires going out of this wire connector.
can_wire_reach(other_connector) | → boolean | Checks if a wire can reach from this connector to the other connector.
Checks if a wire can reach from this connector to the other connector.
have_common_neighbour(other_connector, ignore_ghost_neighbours?) | → boolean | Checks if this and other wire connector have a common neighbour.
Checks if this and other wire connector have a common neighbour.
owner | :: R LuaEntity | The entity this wire connector belongs to. [...]
The entity this wire connector belongs to. [...]
wire_type | :: R defines.wire_type | The type of wires that can be connected to this connector.
The type of wires that can be connected to this connector.
wire_connector_id | :: R defines.wire_connector_id | Identifier of this connector in the entity this connector belongs to.
Identifier of this connector in the entity this connector belongs to.
is_ghost | :: R boolean | If this connector is owned by an entity inside of a ghost. [...]
If this connector is owned by an entity inside of a ghost. [...]
connection_count | :: R uint32 | Amount of wires going out of this connector. [...]
Amount of wires going out of this connector. [...]
connections | :: R array[WireConnection] | All wire connectors this connector is connected to. [...]
All wire connectors this connector is connected to. [...]
real_connection_count | :: R uint32 | Amount of real wires going out of this connector. [...]
Amount of real wires going out of this connector. [...]
real_connections | :: R array[WireConnection] | All wire connectors this connector is connected to with real wires. [...]
All wire connectors this connector is connected to with real wires. [...]
network_id | :: R uint32 | Index of a CircuitNetwork or ElectricSubNetwork which is going through this wire connector. [...]
Index of a CircuitNetwork or ElectricSubNetwork which is going through this wire connector. [...]
valid | :: R boolean | Is this object valid? [...]
Is this object valid? [...]
object_name | :: R string | The class name of this object. [...]
The class name of this object. [...]

## Methods

### is_connected_to(target, origin?) → boolean

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

#### Parameters

target | :: LuaWireConnector | Other connector to check for a connection to.
Other connector to check for a connection to.
origin | :: defines.wire_origin? | Origin of the wire. Defaults to `defines.wire_origin.player`.
Origin of the wire. Defaults to `defines.wire_origin.player`.

### connect_to(target, reach_check?, origin?) → boolean

Connects this connector to other wire connector.

#### Parameters

target | :: LuaWireConnector | Other connector to which a wire should be added.
Other connector to which a wire should be added.
reach_check | :: boolean? | True by default. For wires out of reach or on different surfaces, `false` must be provided.
True by default. For wires out of reach or on different surfaces, `false` must be provided.
origin | :: defines.wire_origin? | Origin of the wire. Defaults to `defines.wire_origin.player`.
Origin of the wire. Defaults to `defines.wire_origin.player`.

#### Return values

→ boolean | Whether a connection was made.

### disconnect_from(target, origin?) → boolean

Disconnects this connector from other wire connector.

#### Parameters

target | :: LuaWireConnector | Other connector to which wire to be removed should be removed.
Other connector to which wire to be removed should be removed.
origin | :: defines.wire_origin? | Origin of the wire. Defaults to `defines.wire_origin.player`.
Origin of the wire. Defaults to `defines.wire_origin.player`.

#### Return values

→ boolean | Whether a connection was removed.

### disconnect_all(origin?) → boolean

Removes all wires going out of this wire connector.

#### Parameters

origin | :: defines.wire_origin? | Origin of the wires to remove. Defaults to `defines.wire_origin.player`.
Origin of the wires to remove. Defaults to `defines.wire_origin.player`.

#### Return values

→ boolean | True if any wire was removed.

### can_wire_reach(other_connector) → boolean

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

#### Parameters

other_connector | :: LuaWireConnector or LuaEntity | Target to which a wire reach is to be checked.
Target to which a wire reach is to be checked.

### have_common_neighbour(other_connector, ignore_ghost_neighbours?) → boolean

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

#### Parameters

other_connector | :: LuaWireConnector | Other connector to check for common neighbour.
Other connector to check for common neighbour.
ignore_ghost_neighbours | :: boolean? |

## Attributes

### owner :: Read LuaEntity

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

### wire_type :: Read defines.wire_type

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

### wire_connector_id :: Read defines.wire_connector_id

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

### is_ghost :: Read boolean

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 :: Read uint32

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

### connections :: Read array[WireConnection]

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

### real_connection_count :: Read uint32

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

### real_connections :: Read array[WireConnection]

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

### network_id :: Read uint32

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 :: Read boolean

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 :: Read string

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.

Class used in

- LuaEntity::get_wire_connector()
- LuaEntity::get_wire_connectors()
- LuaWireConnector::is_connected_to()
- LuaWireConnector::connect_to()
- LuaWireConnector::disconnect_from()
- LuaWireConnector::can_wire_reach()
- LuaWireConnector::have_common_neighbour()
- WireConnection