View Single Post
01-10-18, 10:38 AM   #5
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
Originally Posted by Fizzlemizz View Post
Does it matter the order the addon loads because the function isn't being called until PLAYER_ENTERING_WORLD, unless of course addons receive events in the order they loaded which I have no idea about.

Doesn't AIO only set CVars when you action them in its UI?.

That said, this function will fire every time you see a loading screen. If you want a single event when the game loads use PLAYER_LOGIN.
Frames get events in the order they were registered. If you want a frame to always go last when an event registers, you can find a way to occasionally call UnregisterEvent then RegisterEvent right after, such as in ADDON_LOADED or UNIT_AURA or something like a 5 second OnUpdate. There’s some chat update events that are spammed during loading between ADDON_LOADED and PLAYER_LOGIN you could use if you’re confident addons wouldn’t try to register afterwards.

If you want to ensure your frame goes first, you can do the same thing but with the first return of GetFramesRegisteredForEvent("event"), which returns an ordered list of frames, the first one being the first one that was registered.

“Lua” Code:
  1. local myframe=CreateFrame(‘frame’)
  2. myframe:RegisterEvent(‘event’)
  3. local firstframe=GetFramesRegisteredForEvent(‘event’)
  4. while firstframe~=myframe do
  5.     firstframe:UnregisterEvent(‘event’)
  6.     firstframe:RegisterEvent(‘event’)
  7.     firstframe=GetFramesRegisteredForEvent(‘event’)
  8. end
  Reply With Quote