API:BroadcastEvent
From RoR Wiki
UI Lua API · Interface functions
Version: WAR 1.4.8
Raises a UI event. The event is queued and delivered to all listeners during the next interface update.
BroadcastEvent(eventId)
Arguments
- eventId
number– Id of the event, usually a value fromSystemData.Events.
Returns
Nothing.
Details
- The event is not delivered during the call. The id is added to a queue that the client empties during its next interface update.
- When the queue is emptied, each event is delivered to everything that listens for that id: functions registered with RegisterEventHandler, windows that registered with
WindowRegisterEventHandler, and the client's own listeners. The stock UI relies on the last group to request actions, for exampleBroadcastEvent( SystemData.Events.QUIT )orBroadcastEvent( SystemData.Events.RELOAD_INTERFACE ). - Handlers are called without arguments.
- Events raised by a handler while the queue is being emptied are delivered in the same update, after the events already queued.
- The same id queued several times in a row is delivered only once. For example, three
BroadcastEvent( SystemData.Events.USER_SETTINGS_CHANGED )calls in a row within one frame produce a single delivery. - Event id 0 is never delivered.
- The function takes exactly one argument.
Errors
None besides the Invalid Parameters argument check.
Example
Telling the rest of the UI that settings have changed, from ea_backpackwindow/source/backpackutils.lua:
BroadcastEvent( SystemData.Events.USER_SETTINGS_CHANGED )
From ea_uimodwindow/source/uimodwindow.lua, after enabling or disabling modules:
for index, modData in ipairs( UiModWindow.modsListData ) do
ModuleSetEnabled( modData.name, modData.isEnabled )
end
BroadcastEvent( SystemData.Events.RELOAD_INTERFACE )
