Add sscsm.register_on_sscsms_loaded.
This commit is contained in:
parent
c1a90bbe66
commit
e5edf9a003
|
@ -70,6 +70,12 @@ Registers a server-provided CSM with the following definition table.
|
|||
|
||||
This definition table must have `name` and either `code` or `file`.
|
||||
|
||||
### `sscsm.register_on_sscsms_loaded(function(name))`
|
||||
|
||||
Registers a function to be called when a client loads SSCSMs. Note that this
|
||||
function will not work unless CSMs have the ability to send chat messages as it
|
||||
relies on the SSCSM communication API described below.
|
||||
|
||||
### Communication with SSCSMs
|
||||
|
||||
SSCSM provides an API inspired by
|
||||
|
|
16
init.lua
16
init.lua
|
@ -278,9 +278,18 @@ minetest.override_chatcommand('admin', {
|
|||
})
|
||||
|
||||
-- Add a callback for sscsm:com_test
|
||||
local registered_on_loaded = {}
|
||||
function sscsm.register_on_sscsms_loaded(func)
|
||||
table.insert(registered_on_loaded, func)
|
||||
end
|
||||
|
||||
sscsm.register_on_com_receive('sscsm:com_test', function(name, msg)
|
||||
if type(msg) == 'table' and msg.flags == flags then
|
||||
if type(msg) ~= 'table' or msg.flags ~= flags or has_sscsms[name] then
|
||||
return
|
||||
end
|
||||
has_sscsms[name] = true
|
||||
for _, func in ipairs(registered_on_loaded) do
|
||||
func(name)
|
||||
end
|
||||
end)
|
||||
|
||||
|
@ -311,6 +320,11 @@ minetest.after(0, function()
|
|||
-- If not, enter testing mode.
|
||||
minetest.log('warning', '[SSCSM] Testing mode enabled.')
|
||||
|
||||
sscsm.register_on_sscsms_loaded(function(name)
|
||||
minetest.log('action', '[SSCSM] register_on_sscsms_loaded callback ' ..
|
||||
'fired for user ' .. name)
|
||||
end)
|
||||
|
||||
sscsm.register({
|
||||
name = 'sscsm:testing_cmds',
|
||||
file = modpath .. '/sscsm_testing.lua',
|
||||
|
|
Loading…
Reference in New Issue