Skip to main content

LuaWireConnector

Struct LuaWireConnector 

Source
pub struct LuaWireConnector;
Expand description

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

Implementations§

Source§

impl LuaWireConnector

Source

pub fn connection_count(&self) -> u32

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

Source

pub fn connections(&self) -> Vec<WireConnection>

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

Source

pub fn electric_network(&self) -> LuaElectricSubNetwork

The electric sub network this copper wire connector provides.

No value will be provided if this is not a copper wire connector. May be nil in case of a copper wire connector when it belongs to a ghost or its from a power switch when there are no real wires connecting it to other entities.

Source

pub fn is_ghost(&self) -> bool

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.

Source

pub fn network_id(&self) -> u32

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.

Source

pub fn object_name(&self) -> &str

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.

Source

pub fn owner(&self) -> LuaEntity

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

Source

pub fn real_connection_count(&self) -> u32

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

Source

pub fn real_connections(&self) -> Vec<WireConnection>

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

Source

pub fn valid(&self) -> bool

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.

Source

pub fn wire_connector_id(&self) -> &str

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

Source

pub fn wire_type(&self) -> &str

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

Source

pub fn can_wire_reach(&self, other_connector: LuaAny) -> bool

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

Source

pub fn connect_to( &self, origin: Option<&str>, reach_check: Option<bool>, target: LuaWireConnector, ) -> bool

Connects this connector to other wire connector.

Source

pub fn disconnect_all(&self, origin: Option<&str>) -> bool

Removes all wires going out of this wire connector.

Source

pub fn disconnect_from( &self, origin: Option<&str>, target: LuaWireConnector, ) -> bool

Disconnects this connector from other wire connector.

Source

pub fn have_common_neighbour( &self, ignore_ghost_neighbours: Option<bool>, other_connector: LuaWireConnector, ) -> bool

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

Source

pub fn is_connected_to( &self, origin: Option<&str>, target: LuaWireConnector, ) -> bool

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

Trait Implementations§

Source§

impl Clone for LuaWireConnector

Source§

fn clone(&self) -> LuaWireConnector

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for LuaWireConnector

Source§

impl Debug for LuaWireConnector

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for LuaWireConnector

Source§

fn default() -> LuaWireConnector

Returns the “default value” for a type. Read more
Source§

impl Eq for LuaWireConnector

Source§

impl From<LuaWireConnector> for LuaAny

Source§

fn from(_: LuaWireConnector) -> Self

Converts to this type from the input type.
Source§

impl LuaObject for LuaWireConnector

Source§

impl PartialEq for LuaWireConnector

Source§

fn eq(&self, other: &LuaWireConnector) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for LuaWireConnector

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.