Skip to content

Buffers

Represents a buffer.

Includes an optional parameter for length which will default to datatypes.vlq(3).

The length datatype should NOT be a regular number—instead: use a datatype that represents a number, like a uint, or a range.

function light.datatypes.buff

Shared Synchronous
1
2
3
function buff(
    length: Datatype<number>?
): (Datatype<buffer>)

A couple of ways you could use the optional length parameter:

1
2
3
local types = light.datatypes

local some_buff = types.buff( types.u8 ) -- Buffer between 0-255 bytes
local some_buff = types.buff( types.range(0, 50) ) -- Buffer should be between 0 and 50 bytes.
local some_buff = types.buff( types.literal(3) ) -- A buffer with 3 bytes.