View Single Post
05-03-22, 08:27 AM   #2
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,934
What you can do is make sure you don't do any work in addon 2 until addon 1 has loaded. You can check for the addon loading stage using ADDON_LOADED event.


The way I do it is to monitor for when the active addon is loaded and any required addon is loaded during the ADDON_LOADED event. During that same event check stage I check to make sure all the addons that are needed to be loaded are loaded before progressing further.

Edit:

For example. This is a section from one of my nUI Plugins. To access the nUI stuff it needs to wait until nUI has loaded before doing its own work.

Lua Code:
  1. --[[ Create the InfoPanel Plugin ]]--
  2.     local plugin    = CreateFrame( "Frame", addon:GetInfoPanelName(), nUI_Dashboard.Anchor );
  3.     plugin.active   = true;
  4.  
  5.     --[[ Handle the addons Events ]]--
  6.     local function onEvent(self,event,arg1,arg2,arg3)
  7.         if ( event == "ADDON_LOADED" ) then
  8.             if arg1 == "nUI" then
  9.                 addon.nUILoaded = true
  10.             elseif arg1 == addonName then
  11.                 if not addon.nUILoaded then
  12.                     LoadAddOn("nUI")
  13.                 end
  14.                 addon.nUILoaded = IsAddOnLoaded("nUI")
  15.                 addon.addonLoaded = true
  16.                 addon.plugin = plugin
  17.                 addon:OnAddonLoaded()
  18.                 self:UnregisterEvent(event)
  19.             end
  20.         end
  21.     end

What this basically does is checks if nUI is loaded and set a flag. And check if the plugin addon is loaded. If nUI is loaded first, its just the case of waiting for the plugin to load. But if the plugin is loaded first you can force the base addon to load and check that it has loaded before proceeding. Hopefully it will help you see what you could do with your addon situation to work for you.
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818

Last edited by Xrystal : 05-03-22 at 08:36 AM.
  Reply With Quote