MooUnit-1.0 is a library that provides mappings between GUIDs, unit IDs, and names.
The unit IDs tracked by the library are:
"player"
"vehicle"
"pet"
,"pettarget"
"target"
,"targettarget"
"focus"
,"focustarget"
"arena1"
,...
,"arena5"
"arena1target"
,...
,"arena5target"
"arenapet1"
,...
,"arenapet5"
"arenapet1target"
,...
"arenapet5target"
"boss1"
,...
,"boss5"
"boss1target"
,...
,"boss5target"
"party1"
,...
,"party4"
"party1target"
,...
,"party4target"
"partypet1"
,...
,"partypet4"
"partypet1target"
,...
,"partypet4target"
"raid1"
,...
,"raid40"
"raid1target"
,...
,"raid40target"
"raidpet1"
,...
,"raidpet40"
"raidpet1target"
,...
,"raidpet40target"
"nameplate1"
,...
"nameplate1target"
,...
Returns whether the unit ID receives unit events, e.g., UNIT_AURA
, UNIT_TARGET
, etc.
boolean = lib:HasUnitEvents(unit)
unit
- string: unit ID, e.g.,"player"
,"party1"
,"raid15"
, etc.
boolean
- boolean:true
if the unit receives unit events, orfalse
otherwise
Returns the GUID currently associated with the unit.
guid = lib:GetGUIDByUnit(unit)
unit
- string: unit ID, e.g.,"player"
,"party1"
,"raid15"
, etc.
guid
- string: GUID of the unit
Returns a list of units currently associated with the GUID.
unit1, unit2, ..., unitN = lib:GetUnitByGUID(guid)
guid
- string: GUID
unit1, unit2, ..., unitN
- list of strings: variable-length list of unit ID strings
Returns the name currently associated with the unit.
name = lib:GetNameByUnit(unit)
unit
- string: unit ID, e.g.,"player"
,"party1"
,"raid15"
, etc.
name
- string: the name of the unit,name
orname-realm
Returns a list of units currently associated with the name.
unit1, unit2, ..., unitN = lib:GetUnitByName(name)
name
- string:name
orname-realm
unit1, unit2, ..., unitN
- list of strings: variable-length list of unit ID strings
Returns the name currently associated with the GUID.
name = lib:GetNameByGUID(guid)
guid
- string: GUID
name
- string: the name associated with the GUID,name
orname-realm
Returns a list of GUIDs currently associated with the name.
guid1, guid2, ..., guidN = lib:GetGUIDByName(name)
name
- string:name
orname-realm
guid1, guid2, ..., guidN
- list of strings: variable-length list of GUID strings
Returns the unit ID assigned to the pet for the unit, even if the pet does not exist.
petUnit = lib:GetPetUnitByUnit(unit)
unit
- string: unit ID, e.g.,"player"
,"party1"
,"raid15"
, etc.
petUnit
- string: unit ID, e.g.,"pet"
,"partypet1"
,"raidpet15"
, etc.
Returns the GUID of the owner of the pet or vehicle GUID if both are on the group roster.
ownerGUID = lib:GetOwnerGUIDByGUID(guid)
guid
- string: GUID of the pet or vehicle
ownerGUID
- string: GUID of the owner
Returns the unit ID assigned to the target for the unit, even if the target does not exist.
targetUnit = lib:GetTargetUnitByUnit(unit)
unit
- string: unit ID, e.g.,"player"
,"party1"
,"raid15"
, etc.
targetUnit
- string: unit ID, e.g.,"target"
,"party1target"
,"raid15target"
, etc.
Returns whether the GUID is on the group roster.
boolean = lib:IsGUIDInGroup(guid)
guid
- string: GUID to test group membership
boolean
- boolean:true
if the unit is on the group roster, orfalse
otherwise
Returns whether the unit ID exists and is a group unit ID, e.g., "partypet1"
, "raid15"
, etc.
boolean = lib:IsGroupUnit(unit)
unit
- string: unit ID, e.g.,"player"
,"party1"
,"raid15"
, etc.
boolean
- boolean:true
if the unit exists and is a group unit ID, orfalse
otherwise
Returns an iterator that gives key-value pairs of GUID and unit ID for members on the group roster.
for guid, unit in lib:IteratorRoster() do
...
end
Registers a function to handle the specified callback.
lib.RegisterCallback(handler, callback, method, arg)
handler
- table/string: your addon object or another table containing a function athandler[method]
, or a string identifying your addoncallback
- string: the name of the callback to be registeredmethod
- string/function/nil: a key into thehandler
table, or a function to be called, ornil
ifhandler
is a table and a function exists athandler[callback]
arg
- a value to be passed as the first argument to the callback function specified bymethod
- If
handler
is a table,method
is a string, andhandler[method]
is a function, then that function will be called withhandler
as its first argument, followed by the callback name and the callback-specific arguments. - If
handler
is a table,method
is nil, andhandler[callback]
is a function, then that function will be called withhandler
as its first argument, followed by the callback name and the callback-specific arguments. - If
handler
is a string andmethod
is a function, then that function will be called with the callback name as its first argument, followed by the callback-specific arguments. - If
arg
is non-nil, then it will be passed to the specified function. Ifhandler
is a table, thenarg
will be passed as the second argument, pushing the callback name to the third position. Otherwise,arg
will be passed as the first argument.
Unregisters a specified callback.
lib.UnregisterCallback(handler, callback)
handler
- table/string: your addon object or a string identifying your addoncallback
- string: the name of the callback to be unregistered
MooUnit-1.0 provides the following callbacks to notify interested addons.
Fires when the pet associated with an owner has changed. This can happen if a pet is dismissed and a new pet is summoned.
ownerGUID
- string: GUID of the pet ownerownerUnit
- string: unit ID of the pet ownerpetGUID
- string: GUID of the petpetUnit
- string: unit ID of the pet
Fires when the roster of the party or raid group has changed.
Fires when a unit that we are tracking has changed.
guid
- string: GUID associated with the unit IDunit
- string: unit ID of the unit that has changedname
- string: the current name associated with the unit ID.
Fires when a new member is added to the group roster.
guid
- string: GUID of the member that joined the groupunit
- string: unit ID of the member that joined the group
Fires when a member is removed from the group roster.
guid
- string: GUID of the member that left the group
MooUnit-1.0 is released under the 2-clause BSD license.