Wikia

WoWWiki

Watchlist Recent changes

API UnitClass

Main Menue



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

localizedClass, englishClass = UnitClass("unit");

Parameters Edit

Arguments Edit

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

Returns Edit

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 with no spaces, e.g. "MAGE", "WARRIOR", "DEATHKNIGHT", etc.

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

Pages on WoWWiki

94,142pages on
this wiki
Advertisement | Your ad here

Latest Photos

Add a Photo
55,609photos on this wiki
See more >

Recent Wiki Activity

See more >

Recent Questions

Around Wikia's network

Random Wiki