Skip to content

Message

Message does the same thing as a light.container(), but doesn't force you to put it in a string map.

function light.message (On The Client)

Shared Synchronous Yielding
1
2
3
4
function message<Data>(
    name: string,
    template: Datatype<Data>
): (Message<Data>)

function light.message (On The Server)

Shared Synchronous
1
2
3
4
function message<Data>(
    name: string,
    template: Datatype<Data>
): (Message<Data>)

template in both above samples should always be any valid Datatype. This includes Datatypes like arrays or maps that are defined with luau tables. I.e., { light.datatypes.u8 }

If you wanted to create messages en-masse without restricting yourself to the structure of a container, this can be very useful. You could also use it to re-invent the wheel:

1
2
3
4
5
local ty = light.datatypes

return light.container({
    abc = { ty.u8 }, -- send a table of u8 numbers
})

Is equivalent* to:

1
2
3
return {
    abc = light.message("abc", { light.u8 })
}