Thread Tools Display Modes
10-15-10, 06:09 PM   #1
Dajova
A Wyrmkin Dreamwalker
 
Dajova's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2007
Posts: 58
function to check talent

ok so im trying to fix a function for my mod that can determine what spec i am based on the spellid it checks for (eg. spec specific spells, like Lava Lash for Shaman)

However, i've come to a brick wall here :/ This is the current function i am using atm.

Code:
local function CheckForKnownTalent(spellid)
    local wanted_name = GetSpellInfo(spellid)
    if not wanted_name then return nil end
    local num_tabs = GetNumTalentTabs()
    for t=1, num_tabs do
        local num_talents = GetNumTalents(t)
        for i=1, num_talents do
            local name_talent, _, _, _, current_rank = GetTalentInfo(t,i)
            if name_talent and (name_talent == wanted_name) then
                if current_rank and (current_rank > 0) then
                    return true
                else
                    return false
                end
            end
        end
    end
    return false
end
EDIT: Oh and this is the call for the function
Code:
local spell1
local spell2
if CheckForKnownTalent(78674) then
    spell1 = GetSpellInfo(81192) -- Lunar Shower
elseif CheckForKnownTalent(33878) then
  spell2 = GetSpellInfo(33745) -- Lacerate  
end
I don't know what i am doing wrong, cause it returns... well, i dont know, cause i dont even get a error
__________________
Livestream | Twitter | YouTube

Last edited by Dajova : 10-15-10 at 06:17 PM.
  Reply With Quote
10-15-10, 11:41 PM   #2
brotherhobbes
A Rage Talon Dragon Guard
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 313
If you just want the general spec, you can use something like

if GetPrimaryTalentTree() == 2 then
-- enhancement
end

Example: for shaman, 1 = ele, 2 = enh, 3 = resto, 0 = you haven't selected yet

The function name is misleading, it returns what your current active spec is, not what you have assigned to your Primary/Secondary spec.

Anyway, this should be much easier for you to use.
  Reply With Quote
10-16-10, 06:33 AM   #3
Dajova
A Wyrmkin Dreamwalker
 
Dajova's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2007
Posts: 58
Ah ok. Looks fair enough.
This is what i have atm, should work.

Code:
   if unit == 'player' and GetPrimaryTalentTree() == 1 then
      local _,_,_,count = UnitBuff('player', GetSpellInfo(81192))
__________________
Livestream | Twitter | YouTube
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » function to check talent


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