Skip to main content

traceless.events

Callbacks belong to the running script. Unload removes its registrations. Errors are logged without automatically unregistering the callback. See fixed callbacks and callback objects.

on​

traceless.events.on(name, callback)

Returns: none.

Requires a nonempty event name of at most 63 bytes and a function, while a script is running. Registers another callback, so repeated calls may produce duplicate invocation. Unknown names can be registered but only dispatched names run. Registration allocation failures raise errors.

off​

traceless.events.off(name, callback)

Returns: none.

Removes the first matching registration by event name and function identity. A different closure does not match. Does nothing outside a running script or when the callback is not a function or no match exists.

local traceless = require("traceless")
local function on_paint()
traceless.render.indicator(255, 92, 95, 255, "ready")
end
traceless.events.on("paint", on_paint)
-- Later, from a script invocation:
-- traceless.events.off("paint", on_paint)