Skip to content

Strings

Represents a string value.

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.str

Shared Synchronous
1
2
3
function str(
    length: Datatype<number>?
): Datatype<string>

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

1
2
3
local ty = light.datatypes

local some_str = ty.str( ty.u8 ) -- length between 0-255
local some_str = ty.str( ty.range(0, 50) ) -- String should be between length 0 and 50.
local some_str = ty.str( ty.literal(3) ) -- A string of length 3.