API UnitClass

From Wowpedia
Jump to: navigation, search

Returns the class of the specified unit.

className, classFilename, classID = UnitClass("unit")

Arguments

unit
string - unit to query, e.g. "player"

Returns

className 
string - Localized class name, suitable for use in user interfaces; e.g. "Mage", "Warrior", "Guerrier".
classFilename 
string - Localization-independent class name, used as some table keys; e.g. "MAGE", "WARRIOR", "DEATHKNIGHT".
classID 
number - Numeric localization-independent class ID. (Added in 5.0.1)

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

local name, class = UnitClass("target")
MyAddOn_Classes[class] = name -- store the localized name of the class

Patch history

See also