callbacks
Subscribe functions to events like on_paint; handlers drop when their script reloads or stops.
Functions
callbacks.register
callbacks.register(event, fn)| Name | Type | Description |
|---|---|---|
| event | string | Event name, like "on_paint". |
| fn | function | Gets 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| Name | Type | Description |
|---|---|---|
| event | string | Event it was registered under. |
| fn | function | The 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.