Thread Tools Display Modes
04-15-13, 03:58 AM   #1
akgis
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 29
getting player class(Warlock hunter etc)

How can I get the class that its currently played to do something like

If class="warlock" then
...
end
__________________
  Reply With Quote
04-15-13, 04:32 AM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Code:
local className, englishClassName = UnitClass("player")
if englishClassName == "WARLOCK" then
    -- do something
end
For basic stuff like this, you can usually find the answer by using your browser's "find in page" feature on the list of global functions on Wowpedia.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
04-15-13, 06:18 AM   #3
akgis
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 29
ok thanks for that page.

Would that works on a Spanish client for example?
__________________
  Reply With Quote
04-15-13, 06:55 AM   #4
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
The first value is the localized name, the second is not localized so will always be "WARLOCK" regardless of the client's language.
  Reply With Quote
04-15-13, 12:26 PM   #5
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
To expand on what semlar said... For your if-then statement above:

If you only want your addon to work on the Spanish client, use the first return.

If you want your addon to work regardless of localization (on any client), use the second return.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
04-15-13, 12:55 PM   #6
Haleth
This Space For Rent
 
Haleth's Avatar
Featured
Join Date: Sep 2008
Posts: 1,173
Adding to that, you should use the first return when displaying a class's name as text on the screen, so it'll automatically be localized.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » getting player class(Warlock hunter etc)


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off