Library wire
Wire library. Handles wire inputs/outputs, wirelinks, etc.
Functions
| create( entity1, entity2, input, output ) |
Wires the input of Entity1 to the output of Entity2. |
| createInputs( names, types, descriptions ) |
Creates/modifies wire inputs. |
| createOutputs( names, types, descriptions ) |
Creates/modifies wire outputs. |
| delete( entity, input ) |
Deletes the wire leading to the given entity's input. |
| getInputs( ent ) |
Returns a table of entity's inputs |
| getOutputs( ent ) |
Returns a table of entity's outputs |
| self() |
Returns the wirelink representing the current instance's entity. |
| setName( entity, name ) |
Sets the wire name of the entity (i.e. the name used by the wire namer tool). |
Tables
Fields
Functions
- wire.create( entity1, entity2, input, output )
-
Wires the input of Entity1 to the output of Entity2.
Environment:
Server
Parameters:
-
entity1: The entity to wire from.
-
entity2: The entity to wire to.
-
input: The name of the input on self to wire.
-
output: The name of the output on Ent to wire to.
Return value:
(boolean)
True if successful, false, error if not.
- wire.createInputs( names, types, descriptions )
-
Creates/modifies wire inputs. All wire ports must begin with an uppercase
letter and contain only alphanumeric characters.
Environment:
Server
Parameters:
-
(table) names: An array of input names. May be modified by the function.
-
(table) types: An array of input types. May be modified by the function. See wire.PORT_TYPE_*.
Available types:
- "normal"/"number"
- "string"
- "vector"
- "vector2"
- "vector4"
- "angle"
- "table"
- "array"
- "wirelink"
- "entity"
-
(table?) descriptions: An optional array of input descriptions. May be modified by the function.
Usage:
-- Creates 2 wire inputs, a string and a number.
wire.createInputs( { "MyStringInput", "MyNumberInput" }, { "string", "normal" }, { "A string input.", "A number input." } )
- wire.createOutputs( names, types, descriptions )
-
Creates/modifies wire outputs. All wire ports must begin with an uppercase
letter and contain only alphanumeric characters.
Environment:
Server
Parameters:
-
(table) names: An array of output names. May be modified by the function.
-
(table) types: An array of output types. May be modified by the function. See wire.PORT_TYPE_*.
Available types:
- "normal"/"number"
- "string"
- "vector"
- "vector2"
- "vector4"
- "angle"
- "table"
- "array"
- "entity"
-
(table?) descriptions: An optional array of output descriptions. May be modified by the function.
Usage:
-- Creates 2 wire outputs, a string and a number.
wire.createOutputs( { "MyStringOutput", "MyNumberOutput" }, { "string", "normal" }, { "A string output.", "A number output." } )
- wire.delete( entity, input )
-
Deletes the wire leading to the given entity's input.
Environment:
Server
Parameters:
-
entity: The entity to delete the wire from.
-
input: The name of the input to unwire.
Return value:
(boolean)
True if successful, false, error if not.
- wire.getInputs( ent )
-
Returns a table of entity's inputs
Environment:
Server
Parameters:
-
ent: Entity with input(s)
Return value:
(table | nil)
Table of entity's inputs, if it has any. Otherwise nil.
- wire.getOutputs( ent )
-
Returns a table of entity's outputs
Environment:
Server
Parameters:
-
ent: Entity with output(s)
Return value:
(table | nil)
Table of entity's outputs, if it has any. Otherwise nil.
- wire.self()
-
Returns the wirelink representing the current instance's entity.
Environment:
Server
Return value:
(Wirelink | nil)
The wirelink for the current instance's entity.
- wire.setName( entity, name )
-
Sets the wire name of the entity (i.e. the name used by the wire namer tool).
Environment:
Server
Parameters:
-
(Entity) entity: The entity to set the name for.
-
(string) name: The name to assign to the entity.
Return values:
-
(boolean)
True if the name was set, false otherwise.
-
(string)
If the name could not be set, the reason why.
Tables
- wire.ports
- Ports table. Reads from this table will read from the wire input
of the same name. Writes will write to the wire output of the same name.