View Single Post
03-02-18, 04:16 PM   #2
aallkkaa
A Warpwood Thunder Caller
 
aallkkaa's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2017
Posts: 98
In my rather limmited experience with WoW events, they tend to fire more often than we expect. i.e. when you don't expect them to. And sometimes they don't fire when it would be logical (at least according to our expectations) for them to. Zoneing in and out of instances are moments when this often happens.

So, if I understood correctly, you're only calling GetTalentInfo upon ACTIVE_TALENT_GROUP_CHANGED, right?
I'm guessing maybe that event is fireing in between PLAYER_LEAVING_WORLD and PLAYER_ENTERING_WORLD, making the access to talents unavailable in that period. It may be that they become available again on PLAYER_ENTERING_WORLD (and you'd expect ACTIVE_TALENT_GROUP_CHANGED to fire again but it doesn't).
I have tested nothing of the above, it's just guess-work!. But you could try this:

Lua Code:
  1. local f = CreateFrame("Frame")
  2.  
  3. local function MyUpdateTalentsHandler(self, ...)
  4.     local _, _, _, selected = GetTalentInfo(7, 1, 1)
  5.  
  6.     if selected then
  7.         objectA:Show()
  8.     else
  9.         objectA:Hide()
  10.     end
  11.  
  12.     _, _, _, selected = GetTalentInfo(1, 1, 1)
  13.  
  14.     if selected then
  15.         objectB:Show()
  16.         objectB:RegisterEvent("PLAYER_TARGET_CHANGED")
  17.     else
  18.         objectB:Hide()
  19.         objectB:UnregisterEvent("PLAYER_TARGET_CHANGED")
  20.     end
  21. end
  22.  
  23. f:ACTIVE_TALENT_GROUP_CHANGED = MyUpdateTalentsHandler
  24. f:PLAYER_ENTERING_WORLD = MyUpdateTalentsHandler
  25.  
  26. f:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED")
  27. f:RegisterEvent("PLAYER_ENTERING_WORLD")
  28. f:SetScript("OnEvent", function(self, event, ...)
  29.     self[event](self, ...)
  30. )

Last edited by aallkkaa : 03-02-18 at 04:19 PM. Reason: Fixed typo
  Reply With Quote