Frame:RegisterUnitEvent

From Warcraft Wiki
Jump to navigation Jump to search

Registers the frame for a specific event, triggering only for the specified units.

registered = Frame:RegisterUnitEvent(eventName [, unit1, ...])

Arguments

eventName
string - Name of the frame event.
unit1, ...
string? : UnitId - A list of units (up to four units).

Returns

registered
boolean

Details

  • Repeated calls will overwrite old registrations. Calling Frame:RegisterEvent will also overwrite the old registration.
  • If no unit is given, then all units will be watched; which is virtually the same as calling Frame:RegisterEvent.

Example

local function OnEvent(self, event, ...)
	print(event, ...)
end

local f = CreateFrame("Frame")
f:RegisterUnitEvent("UNIT_HEALTH", "player", "party1", "party2", "party3")
f:SetScript("OnEvent", OnEvent)

Patch changes

Mists of Pandaria Patch 5.0.4 (2012-08-28): Added.