Modchannels#
Allows server side mods (SSMs) communication to client side mods (CSMs) and vice versa.
Server Side API#
Functions#
core.mod_channel_join(channel_name)#
channel_name: string, modchannel name
Returns an object for use with Methods. Creates the channel if it does not exist and joins the channel.
core.register_on_modchannel_message(function(channel_name, sender, message))#
channel_name: string, modchannel name (already joined)sender: string, empty if from a SSM, player name if from a clientmessage: string, message
Used for handling messages received from the client.
Methods#
Note
channel here means the object returned by core.mod_channel_join.
channel:leave()#
The server will leave the channel, meaning no more messages from this channel on core.register_on_modchannel_message
Tip
Set the channel to nil afterwards to free resources
channel:is_writeable()#
- Returns
bool:truetrue if the channel is writeable,falseif it’s not.
channel:send_all(message)#
message: string, limited to 65535 bytes
Sends to all SSMs and CSMs on the channel.
Info
The message will not if channel is not writable or invalid.
Client Side API#
Functions#
core.mod_channel_join(channel_name)#
channel_name: string, modchannel name
Returns an object for use with Methods. Creates the channel if it does not exist and joins the channel. Is equivalent to the the server side function.
core.register_on_modchannel_message(function(channel_name, sender, message))#
channel_name: string, modchannel name (already joined and received acknowledgement)sender: string, empty if from a SSM, player name if from a clientmessage: string, message
Used for handling messages received from the client. Is equivalent to the the server side function.
core.register_on_modchannel_signal(function(channel_name, signal))#
channel_name: string, channel name that the signal has come in onsignal: integer, 0 - 5join_okjoin_failedleave_okleave_failedevent_on_not_joined_channelstate_changed
Used to handle signals generated by the mod channel system.
Methods#
Note
channel here means the object returned by core.mod_channel_join.
channel:leave()#
The client will leave the channel, meaning no more messages from this channel on core.register_on_modchannel_message
Tip
Set the channel to nil afterwards to free resources
channel:is_writeable()#
- Returns
bool:truetrue if the channel is writeable,falseif it’s not.
channel:send_all(message)#
message: string, limited to 65535 bytes
Sends to all SSMs and CSMs on the channel.
Info
The message will not if channel is not writable or invalid.