Thread Tools Display Modes
02-01-10, 04:56 PM   #1
suicidalkatt
A Rage Talon Dragon Guard
 
suicidalkatt's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 331
ACTIVE_TALENT_GROUP_CHANGED firing on log in?

Is there any way to prevent the ACTIVE_TALENT_GROUP_CHANGED from firing on log in?

Someone suggested using a dummy frame and using the OnUpdate of the frame to avoid it firing too soon in the addon load sequence.

Code:
-- Dual Spec Talent Change
local setDualSpec = CreateFrame('Frame')
setDualSpec:RegisterEvent('ACTIVE_TALENT_GROUP_CHANGED')
setDualSpec:SetScript('OnEvent', function(self, event)
	setDualSpec:Show()
	print(tostring(event))
end)
setDualSpec:Hide()
setDualSpec:SetScript('OnUpdate', function()
	local Active = GetActiveTalentGroup()
	local t = TidyPlatesThreat.db.char.specInfo[Active]
	TidyPlatesThreat.db.char.threat.tanking = currentRoleBool(GetActiveTalentGroup())
	print("|cff89F559Threat Plates|r: Player spec change detected: |cff"..classColors[PlayerClass]..specName()..": ("..t[1].."/"..t[2].."/"..t[3]..")|r, you are now in your |cff89F559"..dualSpec(current).."|r spec and are now in your "..roleText(current).." role.")
	TidyPlates:ForceUpdate()
	setDualSpec:Hide()
end)
However it still will fire and display on log in.

Any thoughts?
  Reply With Quote
02-01-10, 05:04 PM   #2
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 822
Why not store the value of talentgroup when you last checked ?
Something like
Code:
If Active ~= OldActive then
  OldActive = Active
  [... Whatever ...]
end
__________________
The cataclysm broke the world ... and the pandas could not fix it!
  Reply With Quote
02-01-10, 05:16 PM   #3
suicidalkatt
A Rage Talon Dragon Guard
 
suicidalkatt's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 331
Originally Posted by Rilgamon View Post
Why not store the value of talentgroup when you last checked ?
Something like
Code:
If Active ~= OldActive then
  OldActive = Active
  [... Whatever ...]
end
I could but it's not really needed.

Any help on my problem?
  Reply With Quote
02-01-10, 05:32 PM   #4
suicidalkatt
A Rage Talon Dragon Guard
 
suicidalkatt's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 331
I could always just make a variable and set it to a value on the ADDON_LOADED then set it to something else on PLAYER_ALIVE or w/e.

... but that seems like the improper thing to do.

Is there something I'm missing?
  Reply With Quote
02-01-10, 06:17 PM   #5
Recluse
A Cliff Giant
 
Recluse's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 70
Just use a flag to suppress the first firing of the event from doing anything?
lua Code:
  1. local suppressed
  2. local f = CreateFrame("Frame")
  3. f:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED")
  4. f:SetScript("OnEvent", function()
  5.     if not suppressed then
  6.         suppressed = true
  7.         return
  8.     end
  9.    
  10.     -- Do yer stuffs!
  11. end)
Similar (maybe the same?) as the other poster mentioned, you could also do the following, which just uses the spec as the flag.
lua Code:
  1. local previous_spec
  2. local f = CreateFrame("Frame")
  3. f:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED")
  4. f:SetScript("OnEvent", function()
  5.     if not previous_spec then
  6.         previous_spec = GetActiveTalentGroup()
  7.         return
  8.     end
  9.    
  10.     local current_spec = GetActiveTalentGroup()
  11.     if current_spec ~= previous_spec then
  12.         previous_spec = current_spec
  13.  
  14.         -- Do yer stuffs!
  15.     end
  16. end)
__________________
We'd be together, but only diamonds last forever...

Last edited by Recluse : 02-01-10 at 06:25 PM.
  Reply With Quote
02-01-10, 06:25 PM   #6
Katae
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Jun 2007
Posts: 208
Here's the solution I used in litestats. You can register/unregister on player_leaving_world or player_entering_world. It will then no longer fire during login:
Code:
local f = CreateFrame'frame'
f:RegisterEvent'PLAYER_ENTERING_WORLD'
f:RegisterEvent'PLAYER_LEAVING_WORLD'

f:SetScript("OnEvent", function(self, event, ...)
    if event == "PLAYER_ENTERING_WORLD" then
        self:RegisterEvent'ACTIVE_TALENT_GROUP_CHANGED'
    elseif event == "PLAYER_LEAVING_WORLD" then
        self:UnregisterEvent'ACTIVE_TALENT_GROUP_CHANGED'
    elseif event == "ACTIVE_TALENT_GROUP_CHANGED" then
        -- Talent stuff.
    end
end)
Disclaimer: I use this for PLAYER_TALENT_UPDATE, which might be a better event to watch, depending on what you use it for.

Last edited by Katae : 02-01-10 at 06:28 PM.
  Reply With Quote
02-01-10, 07:24 PM   #7
suicidalkatt
A Rage Talon Dragon Guard
 
suicidalkatt's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 331
Thank you all for your suggestions

They're much appreciated!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » ACTIVE_TALENT_GROUP_CHANGED firing on log in?


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