UnitName
Jump to navigation
Jump to search
Returns the name and realm of the unit.
name, realm = UnitName(unit) = UnitFullName(unit) = UnitNameUnmodified(unit)
Arguments
- unit
- string : UnitId - For example
"player"
or"target"
Returns
- name
- string? - The name of the unit. Returns
nil
if the unit doesn't exist, e.g. the player has no target selected. - realm
- string? - The normalized realm the unit is from, e.g.
"DarkmoonFaire"
. Returnsnil
if the unit is from the same realm.
Details
- Will return globalstring
UNKNOWNOBJECT
"Unknown Entity" if called before the unit in question has been fully loaded into the world. - The unit name will change if the unit is under the effects of [Lifegiving Seed] or a similar effect, but
UnitNameUnmodified()
is unaffected by this.
Example
- Prints your character's name.
/dump UnitName("player") -- "Leeroy", nil
- Prints the name and realm of your target (if different).
/dump UnitName("target") -- "Thegnome", "DarkmoonFaire"
UnitFullName()
is equivalent withUnitName()
except it will always returnrealm
if used with the "player" UnitId.
/dump UnitFullName("player") -- "Leeroy", "MoonGuard"
/dump UnitFullName("target") -- "Leeroy", nil
GetUnitName
GetUnitName(unit [, showServerName])
can return the combined unit and realm name.
- If
showServerName
is true and the queried unit is from a different server, then the return value will include the unit's name appended by a dash and the normalized realm name. - If
showServerName
is false, thenFOREIGN_SERVER_LABEL
" (*)"
will be appended to units from coalesced realms. Units from the player's own realm or Connected Realms get no additional suffix.
Unit is from the same realm.
/dump GetUnitName("target", true) -- "Nephertiri"
/dump GetUnitName("target", false) -- "Nephertiri"
Unit is from a different realm but the same Connected Realm (LE_REALM_RELATION_VIRTUAL).
/dump GetUnitName("target", true) -- "Standron-EarthenRing"
/dump GetUnitName("target", false) -- "Standron"
Unit is from a different, non-connected realm (LE_REALM_RELATION_COALESCED).
/dump GetUnitName("target", true) -- "Celturio-Quel'Thalas"
/dump GetUnitName("target", false) -- "Celturio (*)"
Patch changes
- Patch 1.12.0 (2006-08-22): Added
realm
return value.[1]