Skip to content

Unit frame functions and fields

Shadowed edited this page Sep 13, 2010 · 8 revisions

All unit frames include data and functions to help identify what they are, and interact with them.

Data

frame Unit frame, named either SUFUnit or SUFHeader<party/raid>UnitButton#
Name Type Description
unit string UnitID, player, party5 and so on.
unitID number/nil Unit number, only applies to units with a number inside them, party5 → 5, raid24 → 24, player → nil
unitType string Unit type without numbers, player → player, raid3 → raid, party5 → party and so on.
visibility table List of modules that are enabled, indexed by the key passed in RegisterModule. visibility = {[“healthBar”] = true, [“castBar”] = false, [“auras”] = false} would indicate that the health bar is enabled, but the cast bar and auras are not.

Functions

All events call the function passed as handler[function](handler, event, ...) where … is any event arguments.

frame:RegisterNormalEvent(event, handler, function)

Register an event that is not filtered by unitid.
Arg Type Description
event string Event name, RAID_ROSTER_UPDATE and so on
handler table Handler that contains the funciton you will pass, the health bar passes Health for example
function string Function name, for the Health bar this could be “Update” which is then called as Health:Update(event, …)

frame:RegisterUnitEvent(event, handler, function)

Register an event that is filtered by the unitid, if you register UNIT_HEALTH your handler/function will only be called if it’s related to the frames unit.
Arg Type Description
event string Event name, UNIT_HEALTH, UNIT_MANA and so on
handler table Handler that contains the funciton you will pass, the health bar passes Health for example
function string Function name, for the Health bar this could be “Update” which is then called as Health:Update(event, …)

frame:RegisterUpdateFunc(handler, function)

Register a handler/function to be called when a full update is triggered. Full updates happen when an unit is enabled, shown, profiles changed, or the profiles finished changing. You should assume everything might have changed when this is called.
Arg Type Description
handler table Handler that contains the funciton you will pass, the cast bar passes Cast for example
function string Function name, for the Health bar this could be “UpdateAll” which is then called as Cast:UpdateAll()

frame:UnregisterAll(handler)

Unregister all events and functions associated with the handler, this is called in your module:OnDisable() function typically..
Arg Type Description
handler table Handler that all event and update functions associated with this should be unregistered for the frame.