KcdMp.on_event
Registers the handler for one event name from the game mode.
One handler per name; a second call replaces the first. The handler gets the payload and the name. An error inside it
is logged ([KcdMp] event 'name' handler: ...), never fatal. Events without a handler go to KcdMp.on_any_event.
Syntax
Section titled “Syntax”KcdMp.on_event(name, fn)| Parameter | Type | |
|---|---|---|
name |
string | the event’s name, as the mode sends it |
fn |
function | function(payload, name) end |
Returns
Section titled “Returns”nothing
Example
Section titled “Example”KcdMp.on_event("marker", function(payload) local x, y, z = payload:match("^([^,]+),([^,]+),(.+)$") marker = {x = tonumber(x), y = tonumber(y), z = tonumber(z)} System.LogAlways("[KcdMp] marker at " .. x .. " " .. y)end)See also
Section titled “See also”KcdMp.on_any_event · KcdMp.send_event · the Script events group of the index
