WoW:API UnitName: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
No edit summary
Line 3: Line 3:


<!-- Describe the purpose of the function, exhausting detail can be saved for a later section -->
<!-- Describe the purpose of the function, exhausting detail can be saved for a later section -->
Returns the name of the specified unit.
Returns the name and realm of the specified unit.


<!-- List return values and arguments as well as function name, follow Blizzard usage convention for args -->
<!-- List return values and arguments as well as function name, follow Blizzard usage convention for args -->
  name = UnitName("unit")
  name, realm = UnitName("unit")





Revision as of 03:31, 25 August 2006

WoW API < UnitName


Returns the name and realm of the specified unit.

name, realm = UnitName("unit")


Parameters

Arguments

("unit")
unit
String - The UnitId to query (e.g. "player", "party2", "pet", "target" etc.)

Returns

name
String - The name of the specified unit.
realm
String - The realm the specified unit is from. If from your own realm, then realm == nil (but the 2nd return value is still there). This is as of 1.12

Example

local playerName = UnitName("player");
ChatFrame1:AddMessage('Hi my name is: ' .. playerName);

Result

Prints the player's name to the chat frame. e.g.
Hi my name is: Octon


Details

UnitName("player") (or any other unit) will return "Unknown Entity" (Actually the value of the UNKNOWNOBJECT global) if called before the unit in question has been fully loaded into the world.