WoW:API UnitClass: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
(Specified parameter (UnitID-String))
(Formatting, another example)
Line 1: Line 1:
<center>'''UnitClass''' ''-Documentation by [[User:Octon|octon]]- Correction by Vjeux''</center>
{{wowapi}} __NOTOC__


Returns the class (Mage, Warrior, etc) of the specified unit.
Returns the class (Mage, Warrior, etc) of the specified unit.


----
localizedClass, englishClass = UnitClass("unit");
;''Arguments''


:[[API_TYPE_UnitId|UnitID]]
== Parameters ==
=== Arguments ===


:;arg1 : The unit to query (e.g. "player")
:;unit: String - the [[unitId]] to query, e.g. "player"


----
=== Returns ===
;''Returns''


:Localized Class
:localizedClass, englishClass
:;localizedclass : The localized class of the specified unit as a string.  e.g. Mage, Warrior, Guerrier, etc.


:English Class
:;localizedclass : The localized class of the specified unit as a string.  e.g. "Mage", "Warrior", "Guerrier", etc.
:;englishclass : The fully english capitalized class of the specified unit as a string.  e.g. MAGE, WARRIOR, etc.


:;englishclass : The fully capitalized english class name, e.g. "MAGE", "WARRIOR", etc.


----
== Example ==
;''Example''
  local playerClass, englishClass = UnitClass("player");
  local playerClass, englishClass = UnitClass("player");
  ChatFrame1:AddMessage('Your player is a : ' .. playerClass .. '; ' .. englishClass);
  ChatFrame1:AddMessage('Your player is a : ' .. playerClass .. '; ' .. englishClass .. '.');


;''Result''
=== Result ===
Prints the player's class to the chat frame as
Prints the player's class to the chat frame, e.g.
   
  Your player is a : Warrior; WARRIOR'.
'Your player is a : Warrior; WARRIOR'. (Or whichever class the specified unit is)


----
== Details ==
;''Description''


: Returns the class (Mage, Warrior, etc) of the specified unit.
For any type of data tracking, use the second parameter, since it is guaranteed to stay the same in different-language clients. This is especially important in europe, where it is not uncommon for people with e.g. german or french client software to play on english servers. You can keep track of mappings for display by remembering the output pairs in a table, e.g.:
: The second return is useful for localized addons.


 
localizedClass, englishClass = UnitClass("target");
----
MyAddOn_Classes[englishClass] = localizedClass;
{{WoW API}}
''.. do data tracking stuff with englishClass..''

Revision as of 11:23, 11 August 2006

WoW API < UnitClass

Returns the class (Mage, Warrior, etc) of the specified unit.

localizedClass, englishClass = UnitClass("unit");

Parameters

Arguments

unit
String - the unitId to query, e.g. "player"

Returns

localizedClass, englishClass
localizedclass
The localized class of the specified unit as a string. e.g. "Mage", "Warrior", "Guerrier", etc.
englishclass
The fully capitalized english class name, e.g. "MAGE", "WARRIOR", etc.

Example

local playerClass, englishClass = UnitClass("player");
ChatFrame1:AddMessage('Your player is a : ' .. playerClass .. '; ' .. englishClass .. '.');

Result

Prints the player's class to the chat frame, e.g.

Your player is a : Warrior; WARRIOR'.

Details

For any type of data tracking, use the second parameter, since it is guaranteed to stay the same in different-language clients. This is especially important in europe, where it is not uncommon for people with e.g. german or french client software to play on english servers. You can keep track of mappings for display by remembering the output pairs in a table, e.g.:

localizedClass, englishClass = UnitClass("target");
MyAddOn_Classes[englishClass] = localizedClass;

.. do data tracking stuff with englishClass..