WoW:API UnitName: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
<center>'''UnitName''' - ''Documentation by [[User:Octon|octon]]''</center>
{{wowapi}} __NOTOC__


== Synopsis ==
 
<!-- 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 of the specified unit.


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


== Arguments ==
 
== Parameters ==
=== Arguments ===
<!-- List each argument, together with its type -->
:("unit")
:("unit")


:;unit : String - The [[API TYPE UnitId|UnitId]] to query (e.g. "player", "party2", "pet", "target" etc.)
:;unit : String - The [[API TYPE UnitId|UnitId]] to query (e.g. "player", "party2", "pet", "target" etc.)


== Returns ==
=== Returns ===
:name
<!-- List each return value, together with its type -->
:;name : String - The name of the specified unit.


:;name : String - The name of the specified unit.


== Example ==
== Example ==
<!-- If it helps, include an example here, though it's not required if the usage is self-explanatory -->
<!-- begin code -->
<!-- begin code -->
  local playerName = UnitName("player");
  local playerName = UnitName("player");
  ChatFrame1:AddMessage('Hi my name is: ' .. playerName);
  ChatFrame1:AddMessage('Hi my name is: ' .. playerName);
<!-- end code -->
<!-- end code -->
==== Result ====
 
====Result====
<!-- If it helps, include example results here, though they are not required. You're allowed to cheat liberally since WoW isn't a command line language. -->
:Prints the player's name to the chat frame. e.g.
:Prints the player's name to the chat frame. e.g.
<!-- begin code -->
<!-- begin code -->
Line 27: Line 35:
<!-- end code -->
<!-- end code -->


== Details ==
 
==Details==
<!-- Details not appropriate for the main description can go here.
    REMOVE the section if you're just going to restate the intro line! -->
 
: 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.
: 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.


 
: '''In the upcoming patch 1.12, it seems that UnitName() returns two values: unit-name and server-name. The second value is only returned when used on a player from another server in a (cross-server) battleground.'''
----
[[Category:World of Warcraft API]]
{{WoW API}}

Revision as of 00:09, 26 July 2006

WoW API < UnitName


Returns the name of the specified unit.

name = 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.


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.
In the upcoming patch 1.12, it seems that UnitName() returns two values: unit-name and server-name. The second value is only returned when used on a player from another server in a (cross-server) battleground.