WoW:API UnitClass: Difference between revisions
Jump to navigation
Jump to search
(Returns the class (Mage, Warrior, etc) of the specified unit.) |
m (Move page script moved page API UnitClass to API UnitClass without leaving a redirect) |
||
(10 intermediate revisions by 10 users not shown) | |||
Line 1: | Line 1: | ||
{{wowapi}} __NOTOC__ | |||
Returns the class (Mage, Warrior, etc) of the specified unit. | Returns the class (Mage, Warrior, etc) of the specified unit. | ||
localizedClass, englishClass, classIndex = UnitClass("unit"); | |||
; | |||
== Parameters == | |||
=== Arguments === | |||
:; | :;unit | ||
:: String - the [[unitId]] to query, e.g. "player" | |||
=== Returns === | |||
: | :localizedClass, englishClass, classIndex | ||
:;localizedclass | |||
; | :: The localized class of the specified unit as a string. e.g. "Mage", "Warrior", "Guerrier", etc. | ||
;'' | :;englishclass | ||
:: The fully capitalized english class name with no spaces, e.g. "MAGE", "WARRIOR", "DEATHKNIGHT", etc. | |||
:;classIndex | |||
:: the number index corresponding to the particular class that is returned. Number mapping is as follows: | |||
::None = 0 | |||
::Warrior = 1 | |||
::Paladin = 2 | |||
::Hunter = 3 | |||
::Rogue = 4 | |||
::Priest = 5 | |||
::DeathKnight = 6 | |||
::Shaman = 7 | |||
::Mage = 8 | |||
::Warlock = 9 | |||
::Monk = 10 | |||
::Druid = 11 | |||
::Demon Hunter = 12 | |||
== 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..'' |
Latest revision as of 04:47, 15 August 2023
Returns the class (Mage, Warrior, etc) of the specified unit.
localizedClass, englishClass, classIndex = UnitClass("unit");
Parameters[edit]
Arguments[edit]
- unit
- String - the unitId to query, e.g. "player"
Returns[edit]
- localizedClass, englishClass, classIndex
- localizedclass
- The localized class of the specified unit as a string. e.g. "Mage", "Warrior", "Guerrier", etc.
- englishclass
- The fully capitalized english class name with no spaces, e.g. "MAGE", "WARRIOR", "DEATHKNIGHT", etc.
- classIndex
- the number index corresponding to the particular class that is returned. Number mapping is as follows:
- None = 0
- Warrior = 1
- Paladin = 2
- Hunter = 3
- Rogue = 4
- Priest = 5
- DeathKnight = 6
- Shaman = 7
- Mage = 8
- Warlock = 9
- Monk = 10
- Druid = 11
- Demon Hunter = 12
Example[edit]
local playerClass, englishClass = UnitClass("player"); ChatFrame1:AddMessage('Your player is a : ' .. playerClass .. '; ' .. englishClass .. '.');
Result[edit]
Prints the player's class to the chat frame, e.g.
Your player is a : Warrior; WARRIOR.
Details[edit]
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..