View Single Post
02-10-12, 10:59 PM   #14
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Grimsin View Post
... even if a file is listed first in the toc, the addon settings are still in an ADDON_LOADED event, and even though its listed before other files, if i use ADDON_LOADED in other files, it has no guaranty it loads first ...
The order in which frames receive an event is undefined. You cannot depend on Frame A receiving an event before Frame B receives the same event.

It sounds like you are simply doing things wrong. If you need multiple files to be aware of when your addon finishes loading, and run setup functions, here is a simple method of handling that that does not require multiple frames handling ADDON_LOADED, or convoluted timer solutions.

In your main file (the one that's loaded first), handle ADDON_LOADED and initializing your saved variables.

Near the top of that file, add:

Code:
MyAddon.loadFunctions = {}
Inside the ADDON_LOADED event handler, after you have initialized saved variables, add:

Code:
for _, methodName in ipairs(MyAddon.loadFunctions) do
	MyAddon[methodName](MyAddon)
end
Then, in each other file, add any functions that need to be run after saved variables are initialized to that table:

Code:
function MyAddon:DoSomething()
	-- Do stuff.
end

table.insert(MyAddon.loadFunctions, "DoSomething")
Originally Posted by Grimsin View Post
the big reason to load as much as possible prior to player login and player entering world is it helps alleviate tainting especially when you reload or relog while in combat
The load order of addons is irrelevant for taint. If something is tainted, it does not matter if it was tainted before or after some event fired; it's still tainted, and it will still cause the same problems (if any).

I think you're thinking of secure frames, and the actions that can only be performed on them outside of combat. In this case, you can still delay performing these actions until PLAYER_LOGIN fires; the UI is not locked down until some time after the PLAYER_REGEN_DISABLED event fires to indicate that the player has been flagged for combat, and you can always check to see if the UI is locked down by calling InCombatLockdown().

It might be more helpful if you are more specific about what code you are trying to run that you think needs to be called before PLAYER_LOGIN.
  Reply With Quote