API GetUnitName

From Wowpedia
Jump to: navigation, search
"I" iconThis function is implemented by FrameXML in FrameXML/UnitFrame.lua.

Returns the name and realm of the specified unit.

name = GetUnitName("unit", showServerName)

Arguments

unit 
String - The UnitId to query (e.g. "player", "party2", "pet", "target" etc.)
showServerName 
Boolean - True to append full server name to units from other servers; false to append a short indicator.

Returns

name 
String - unit's name (and possibly server name), formatted per the specified arguments.

Details

  • If showServerName is true, and the queried unit is from a different server, the returned value will include the unit's name, followed by a dash, and the full name of the server it stems from (e.g. "Bob-Emerald Dream")
  • If showServerName is false, FOREIGN_SERVER_LABEL (" (*)") will be appended to units from coalesced realms. Units from the player's own realm, or Connected Realms, get no additional suffix.

Patch History

Mists of Pandaria Patch 5.4.0 (2013-09-10): Now returns 'name-realm' instead of 'name - realm' (spaces removed).