GetSpecialization() doesn't return correctly right upon login - workaround?
I'm writing an addon where which frames are shown depends a bit on your talent spec, and it seems that right as you log in GetSpecialization() sometimes doesn't return a correct value, most likely because your spec and so on hasn't been loaded in yet.
I am trying to use it in the ADDON_LOADED event, and it seems to work correctly about 50% of the time when logging in, and when I just reload my UI it works more or less 100% of the time. Is there a neat workaround for this? Is there a specific order that events are fired as you log in? |
http://www.wowpedia.org/AddOn_loadin...iables_loading
Don't take this as some kind of bible, event order has changed in the past but it's relatively trustworthy. PLAYER_LOGIN is the event you want for initializing game data most of the time. |
I had the same issue with CRITERIA UPDATE firing twice when logging in, the first one was right after ADDON_LOADED, the second after PLAYER_LOGIN. GetAchievementCriteriaInfo() returned completed data on the second occurence.
|
PLAYER_LOGIN seems to work better and I wasn't able to trigger the error with using that instead, so thanks for that :)
Is there any way that PLAYER_LOGIN could be before ADDON_LOADED in extreme situations? My code right now relies on ADDON_LOADED going first. |
Quote:
lua Code:
lua Code:
|
Have you tried PLAYER_ALIVE or PLAYER_ENTERING_WORLD?
|
Quote:
|
for cases like this where it's ambiguous what data is available when, you can set up a timer to periodically run a simple function that checks for good return results (ie, not nil) on functions you're interested in. if it makes it thru the series of checks, then it kills the timer and fires off the your actual initialization function.
i had to do this to check when profession information is available as no events seem to work 100% of the time. also makes it future proof should blizzard re-arrange event order. |
All times are GMT -6. The time now is 07:24 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI