Encoding

In order for data to be sent between users, it must be encoded as a string and then decoded on the receiving end. When using commands, this is done automatically. However, to do this manually, there are the following functions:

Function Returns Description
onlinePlay.encodeValue​(​type (string), value (any)​)
string Encodes the given value into a string representation. These encoded strings can be concatenated together.
onlinePlay.decodeValue​(​type (string), encoded (string), start (number or nil)​)
any, number Decodes a value from a given string and returns it as its first return value. For an encoded string that contains multiple values, the second return value acts as the start position for the next value to decode.

The type value of these functions can be any of the strings listed below.

Type Description
number
A floating point number.
boolean
A true/false value.
nil
A nil value.
string
A string. Cannot be longer than 65,535 bytes.
table
A Lua table.
list
A Lua table whose keys are consecutive numbers, starting at 1. Note that encoding a list is more efficient than a standard table.
Vector2
A 2D vector object from the Vector class.
Vector3
A 3D vector object from the Vector class.
Vector4
A 4D vector object from the Vector class.
uint8
An integer ranging between 0 and 255.
sint8
An integer ranging between -128 and 127.
uint16
An integer ranging between 0 and 65535.
sint16
An integer ranging between -32768 and 32767.
uint32
An integer ranging between 0 and 4294967295.
sint32
An integer ranging between -2147483648 and 2147483647.
any
Encodes any other type automatically. May not always pick the most efficient type (for instance, it will pick "number" over the more efficient integer types).