I'm looking for a good way to detect the players current spec, I tried to check for the main spec spell (ie Mortal Strike for Warriors) with IsUsableSpell but it doesn't work very good, it returns nil most of the times when I run it on "PLAYER_LOGIN"..
If youre only interested in your own spec, you dont need a library:
local frame = CreateFrame( "Frame" )
frame:RegisterEvent( "PLAYER_LOGIN" )
frame:RegisterEvent( "PLAYER_ALIVE" )
frame:SetScript( "OnEvent", function()
if not GetTalentTabInfo( 1 ) then
return -- Talents aren't loaded yet!
local specID = [URL="http://www.wowpedia.org/API_GetPrimaryTalentTree"]GetPrimaryTalentTree[/URL]()
if specID then
local _, specName = [URL="http://www.wowpedia.org/API_GetTalentTabInfo"]GetTalentTabInfo[/URL]( specID )
DEFAULT_CHAT_FRAME:AddMessage( string.format( "You are a %s %s.", specName, UnitClass( "player" ) ) )
DEFAULT_CHAT_FRAME:AddMessage( "You do not have a primary spec." )
frame:SetScript( "OnEvent", nil )
When you first log in, talent info isnt available until the PLAYER_ALIVE event fires, but when you reload your UI, that event doesnt fire, and talent info is available right away, so you should listen for PLAYER_LOGIN too, to account for either scenario.