#
extern
These are functions that are ported to allow for easy access.
This makes it easier to use instead of just relying on
linker.meta(library: string, name?: string): function | table
and
linker.global(library: string, name?: string): function | table
#
Example
This is an example of how you can use ported functions.
With this you can run it interstate.
-- lua_run util.AddNetworkString("test") net.Receive("test", function() print(net.ReadString()) end)
linker.net.Start("test")
linker.net.WriteString("hello world")
linker.net.SendToServer() -- prints "hello world" on the server
#
NET
You can access this by doing
linker.net.*
net.GetList(): string[]
- Retrieves a list of all network names
net.IDToString(id: number): string?
- Converts a network ID to its string counterpart
net.StringToID(name: string): number?
- Converts a network name to its ID counterpart
net.Start(messageName: string, unreliable?: boolean = false)
- Begins a new net message.
- If another net message is already started and hasn't been sent yet, it will be discarded.
- After calling this function, you will want to call
net.Write*
functions to write your data, if any, and then finish withnet.SendToServer()
net.SendToServer()
- Sends the current net message to the server.
net.WriteBit(boolean: boolean)
- Appends a boolean (as 1 or 0) to the current net message.
net.WriteUInt(value: number, size: number)
- Appends an unsigned integer with the specified number of bits to the current net message.
- For size reference:
1 = bit, 4 = nibble, 8 = byte, 16 = short, 32 = long
net.WriteInt(value: number, size: number)
- Appends an integer with the specified number of bits to the current net message.
- For size reference:
1 = bit, 4 = nibble, 8 = byte, 16 = short, 32 = long
net.WriteString(value: string)
- Appends a string to the current net message.
- The size of the written data is 8 bits for every ASCII character in the string + 8 bits for the null terminator.
net.WriteFloat(value: number)
- Appends a float (number with decimals) to the current net message.
net.WriteDouble(value: number)
- Appends a double (number with decimals) to the current net message.
net.WriteVector(value: Vector)
- Appends a vector to the current net message.
- Vectors sent by this function are compressed, which may result in precision loss.
- XYZ components greater than 16384 or less than -16384 are irrecoverably altered (most significant bits are trimmed) and precision after the decimal point is low.
net.WriteAngle(value: Angle)
- Similar to
net.WriteVector(value: Vector)
however uses a different lua class to inherit Angle metatables
net.WriteMatrix(value: Matrix)
- Writes a VMatrix to the current net message.
net.WriteData(value: string, size: number)
- Writes a chunk of binary data to the message.
- The size determines the length of the message, having a different size than the message size would cut-off or corrupt data.
#
NW
You can access this by doing
linker.nw.*
nw.GetList(target: Entity): {[index: string]: any}
- Retrieves a list of all keys and their data
nw.GetBool(target: Entity, key: string, fallback?: any): boolean | any
- Retrieves a networked boolean value at specified index on the entity.
nw.GetInt(target: Entity, key: string, fallback?: any): number | any
- Retrieves a networked integer (whole number) value at specified index on the entity.
nw.GetFloat(target: Entity, key: string, fallback?: any): number | any
- Retrieves a networked float value at specified index on the entity.
nw.GetString(target: Entity, key: string, fallback?: any): string | any
- Retrieves a networked string value at specified index on the entity.
nw.GetVector(target: Entity, key: string, fallback?: any): Vector | any
- Retrieves a networked vector value at specified index on the entity.
nw.GetAngle(target: Entity, key: string, fallback?: any): Angle | any
- Retrieves a networked angle value at specified index on the entity.
nw.GetEntity(target: Entity, key: string, fallback?: any): Entity | any
- Retrieves a networked entity value at specified index on the entity.
#
NVAR
You can access this by doing
linker.nvar.*
nvar.GetBool(target: Entity, key: number): boolean | nil
- Retrieves a networked boolean value at specified index on the entity.
nvar.GetInt(target: Entity, key: number): number | nil
- Retrieves a networked integer (whole number) value at specified index on the entity.
nvar.GetFloat(target: Entity, key: number): number | nil
- Retrieves a networked float value at specified index on the entity.
nvar.GetString(target: Entity, key: number): string | nil
- Retrieves a networked string value at specified index on the entity.
nvar.GetVector(target: Entity, key: number): Vector | nil
- Retrieves a networked vector value at specified index on the entity.
nvar.GetAngle(target: Entity, key: number): Angle | nil
- Retrieves a networked angle value at specified index on the entity.
nvar.GetEntity(target: Entity, key: number): Entity | nil
- Retrieves a networked entity value at specified index on the entity.