Skip to content

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.

KcdMp.on_event(name, fn)
Parameter Type
name string the event’s name, as the mode sends it
fn function function(payload, name) end

nothing

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)

KcdMp.on_any_event · KcdMp.send_event · the Script events group of the index