xhookLua
Game

callbacks

Subscribe functions to events like on_paint; handlers drop when their script reloads or stops.

Functions

callbacks.register

callbacks.register(event, fn)
NameTypeDescription
eventstringEvent name, like "on_paint".
fnfunctionGets the event's arguments.

Adds an event handler; handlers run in registration order.

  • Names aren't validated: a typo never fires. Duplicates run twice.
  • Errors are logged; other handlers still run.

callbacks.unregister

callbacks.unregister(event, fn) -> integer
NameTypeDescription
eventstringEvent it was registered under.
fnfunctionThe registered function value.

Removes a handler by function identity.

Returns registrations removed

  • Removes it for that event from every script.
  • An inline anonymous function written again never matches.
callbacks ยท Lua API ยท xhook