WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   addon loading order. (https://www.wowinterface.com/forums/showthread.php?t=59119)

Uitat 05-03-22 07:20 AM

addon loading order.
 
I'm suffering from something in my UI that I cant seem to work out,...

here is the situation

Addon 1, Addon2

Addon 1: changes Resolution screen scale,
Addon 2: is a unit frames

if addon 2 loads before addon 1 then the frames are off and wonkie.

I need a way to ensure that Addon 1 is loaded before Addon 2

is there a way to do this, I'm growing frustrated, I have researched until blue in the face and I cant find anything on this issue.

Xrystal 05-03-22 08:27 AM

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.

Fizzlemizz 05-03-22 09:35 AM

Make addon 1 a dependancy of addon 2 in its .toc. Optional or Required depending on wether addon 1 may be installed or not.

## OptDeps: AddOn1
or
## RequiredDeps: AddOn1

Uitat 05-03-22 09:56 AM

ok maybe this will make it more clear, as i am still struggling.

Addon 1 is: _deranjata
Addon 2 is: Shadowed Unit Frames

i want Shadowed unit frames to wait for _deranjata to load before it trys to load

Uitat 05-03-22 10:08 AM

Quote:

Originally Posted by Fizzlemizz (Post 340586)
Make addon 1 a dependancy of addon 2 in its .toc. Optional or Required depending on wether addon 1 may be installed or not.

## OptDeps: AddOn1
or
## RequiredDeps: AddOn1

i tried this and its still doing the baddie,

way to repeat issue so you may test if you wish.

DL and use just Project Deranjata,
DL and Use SUF.

after initial setup, on reload the SUF Bars Change position until you open its config and uncheck and recheck the lock frames section under General.

from all i have read it is because i am changing the CVar's with this code to attain perfect alignment within Project Deranjata

Lua Code:
  1. SetCVar("useuiScale", 1);
  2. SetCVar("displaySpellActivationOverlays", 0);
  3. SetCVar("uiScale", 0.60);

Fizzlemizz 05-03-22 10:34 AM

Yeah, dependancies won't work if you're talking about making your addon a dependacy of someone elses.

Probably need to see if there some way to re-initialise SUF after you've done your changes.

If SUF uses Ace and assuming you are using your own profile to confiugure it then maybe something like:

Code:

-- Do your changes then:
local Shadowed = NS.AceAddons:GetAddon("Shadowed whatever", true)
Shadowed.db:SetProfile("Whatever your profile name is")

I don 't know Shadowed so .db tends to be the convention but may be solmething else.

Fizzlemizz 05-03-22 12:07 PM

With something like SUF, it's highly unlikely your problem is the addon load order but more likely the event and event processing order where SUF does it's actual profile/frame initialisation processing.

Uitat 05-04-22 05:50 AM

may not be my best solution
 
yeah i think this may not be the solution i am looking other direction


All times are GMT -6. The time now is 06:40 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI