Quantcast
Download
(14 Kb)
Download
Updated: 11-12-18 11:03 PM
Pictures
File Info
Compatibility:
Battle for Azeroth (8.0.1)
Updated:11-12-18 11:03 PM
Created:11-06-18 09:49 AM
Downloads:21
Favorites:1
MD5:
8.0.1

MooUnit-1.0  Updated this week!

Version: 2
by: jlam [More]

Overview

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", ...

API Methods

HasUnitEvents

Returns whether the unit ID receives unit events, e.g., UNIT_AURA, UNIT_TARGET, etc.

Code:
boolean = lib:HasUnitEvents(unit)
Arguments:
  • unit - unitID: "player", "target", "raid15", etc.
Returns:
  • boolean - boolean: true if the unit receives unit events, or false otherwise
GetGUIDByUnit

Returns the GUID currently associated with the unit.

Code:
guid = lib:GetGUIDByUnit(unit)
Arguments:
  • unit - unitID: "player", "target", "raid15", etc.
Returns:
  • guid - GUID: the GUID of the unit
GetUnitByGUID

Returns a list of units currently associated with the GUID.

Code:
unit1, unit2, ..., unitN = lib:GetUnitByGUID(guid)
Arguments:
Returns:
  • unit1, unit2, ..., unitN - list of unitID: variable-length list of unit IDs
GetNameByUnit

Returns the name currently associated with the unit.

Code:
name = lib:GetNameByUnit(unit)
Arguments:
  • unit - unitID: "player", "target", "raid15", etc.
Returns:
  • name - string: the name of the unit, name or name-realm
GetUnitByName

Returns a list of units currently associated with the name.

Code:
unit1, unit2, ..., unitN = lib:GetUnitByName(name)
Arguments:
  • name - string: name or name-realm
Returns:
  • unit1, unit2, ..., unitN - list of unitID: variable-length list of unit IDs
GetNameByGUID

Returns the name currently associated with the GUID.

Code:
name = lib:GetNameByGUID(guid)
Arguments:
Returns:
  • name - string: the name associated with the GUID, name or name-realm
GetGUIDByName

Returns a list of GUIDs currently associated with the name.

Code:
guid1, guid2, ..., guidN = lib:GetGUIDByName(name)
Arguments:
  • name - string: name or name-realm
Returns:
  • guid1, guid2, ..., guidN - list of GUID: variable-length list of GUIDs
GetPetUnitByUnit

Returns the unit ID assigned to the pet for the unit, even if the pet does not exist.

Code:
petUnit = lib:GetPetUnitByUnit(unit)
Arguments:
  • unit - unitID: "player", "party1", "raid15", etc.
Returns:
  • petUnit - unitID: "pet", "partypet1", "raidpet15", etc.
GetOwnerByGUID

Returns the GUID of the owner of the pet or vehicle GUID if both are on the group roster.

Code:
ownerGUID = lib:GetOwnerByGUID(guid)
Arguments:
  • guid - GUID: pet or vehicle GUID
Returns:
  • ownerGUID - GUID: GUID of owner.
GetTargetUnitByUnit

Returns the unit ID assigned to the target for the unit, even if the target does not exist.

Code:
targetUnit = lib:GetTargetUnitByUnit(unit)
Arguments:
  • unit - unitID: "player", "party1", "raid15", etc.
Returns:
  • targetUnit - unitID: "target", "party1target", "raid15target", etc.
IterateRoster

Returns an iterator that gives key-value pairs of GUID and unit ID for members on the group roster.

Code:
for guid, unit in lib:IteratorRoster() do
    ...
end
RegisterCallback

Registers a function to handle the specified callback.

Code:
lib.RegisterCallback(handler, callback, method, arg)
Arguments:
  • handler - table/string: your addon object or another table containing a function at handler[method], or a string identifying your addon
  • callback - string: the name of the callback to be registered
  • method - string/function/nil: a key into the handler table, or a function to be called, or nil if handler is a table and a function exists at handler[callback]
  • arg - a value to be passed as the first argument to the callback function specified by method
Notes:
  • If handler is a table, method is a string, and handler[method] is a function, then that function will be called with handler as its first argument, followed by the callback name and the callback-specific arguments.
  • If handler is a table, method is nil, and handler[callback] is a function, then that function will be called with handler as its first argument, followed by the callback name and the callback-specific arguments.
  • If handler is a string and method 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. If handler is a table, then arg will be passed as the second argument, pushing the callback name to the third position. Otherwise, arg will be passed as the first argument.
UnregisterCallback

Unregisters a specified callback.

Code:
lib.UnregisterCallback(handler, callback)
Arguments:
  • handler - table/string: your addon object or a string identifying your addon
  • callback - string: the name of the callback to be unregistered
Callbacks

MooUnit-1.0 provides the following callbacks to notify interested addons.

MooUnit_PetChanged

Fires when the pet associated with an owner has changed. This can happen if a pet is dismissed and a new pet is summoned.

Arguments:
  • ownerGUID - GUID: the GUID of the pet owner
  • ownerUnit - unitID: the unit ID of the pet owner
  • petGUID - GUID: the GUID of the pet
  • petUnit - unitID: the unit ID of the pet
MooUnit_RosterUpdated

Fires when the roster of the party or raid group has changed.

MooUnit_UnitChanged

Fires when a unit that we are tracking has changed.

Arguments:
  • guid - GUID: the GUID associated with the unit ID
  • unit - unitID
  • name - string: the current name associated with the unit ID.
MooUnit_UnitJoined

Fires when a new member is added to the group roster.

Arguments:
  • guid - GUID: the GUID of the member that joined the group
  • unit - unitID: the unit ID of the member that joined the group
MooUnit_UnitLeft

Fires when a member is removed from the group roster.

Arguments:
  • guid - GUID: the GUID of the member that left the group
License

MooUnit-1.0 is released under the 2-clause BSD license.

Feedback

MooUnit-1.0
2 (2018-11-13)
Full Changelog Previous releases
  • Bump the minor version to 2 for release.
  • Add a new method :UnitInGroup() to test for group membership.
  • Improve the documentation of the argument and return types.
  • Slightly optimize the check for whether a unit is the player.
  • Give temporary unit IDs a lower priority.
    Give "permanent" unit IDs like group, boss, or arena unit IDs a
    higher priority than temporary unit IDs like "target" or "focus".
    This makes :GetUnitByGUID() return more stable unit IDs.
  • Add empty line to help with CurseForge's Markdown-to-HTML.
  • Add WoWInterface project ID for use by packager/release.sh.
Optional Files (0)


Archived Files (1)
File Name
Version
Size
Author
Date
1
14kB
jlam
11-06-18 09:49 AM


There have been no comments posted to this file.
Be the first to add one.



Category Jump: