Skip to content

Return of Reckoning

Wiki

RoR Wiki

API:RegisterEventHandler

From RoR Wiki
Revision as of 19:48, 16 October 2026 by Maintenance script (talk | contribs) (UI Lua API import (WAR 1.4.8))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

UI Lua API · Interface functions
Version: WAR 1.4.8

Registers a Lua function to be called whenever a UI event is raised.

RegisterEventHandler(eventId, functionName)

Arguments

eventId
number – Id of the event, usually a value from SystemData.Events.
functionName
string – Name of the Lua function to call, as a dotted path from the global table, for example "MyAddon.OnLoadingEnd". It is a name, not a function value.

Returns

Nothing.

Details

  • Each time the event is raised, the client looks up functionName and calls it. The handler receives the arguments carried by the event. Events raised with BroadcastEvent carry none.
  • One event can have any number of handlers, and one function can handle several events. Registering the same function for the same event a second time is refused with an error.
  • The client remembers which UI module was being loaded or initialized when the handler was registered, and makes that module current while the handler runs.
  • Handlers can register or unregister handlers while an event is being delivered. Each handler is called at most once per delivery.
  • Handlers stay registered until UnregisterEventHandler is called with the same event id and the same name.
  • Handlers that belong to a window are registered with WindowRegisterEventHandler instead; they are stored on the window, not in this list.

Errors

These are written to the UI log; the call returns normally.

  • Error in function call 'RegisterEventHandler': Invalid Event Id (event id 0)
  • Error in function call 'RegisterEventHandler': Invalid Script Name (empty name)
  • Error in function call 'RegisterEventHandler': Script %s is already registered for event #%d

Example

From easystem_actionbarclustermanager/source/actionbarclustermanager.lua:

RegisterEventHandler (SystemData.Events.PLAYER_CAREER_LINE_UPDATED, "ActionBarClusterManager.SpawnCluster")
RegisterEventHandler (SystemData.Events.LOADING_END,                "ActionBarClusterManager.SpawnCluster")

From interfacecore/interfacecore.lua:

RegisterEventHandler( SystemData.Events.RESOLUTION_CHANGED, "InterfaceCore.OnResolutionChanged")

See also