Thread Tools Display Modes
01-16-15, 03:13 PM   #1
Kaitain1977
A Deviate Faerie Dragon
 
Kaitain1977's Avatar
AddOn Compiler - Click to view compilations
Join Date: Jan 2009
Posts: 12
Detect if addon is loaded

I'm trying to get a line of script (to change a profile) to run only if a certain addon is loaded, and if it isn;t then totally ignore it. I thought it was done like this:

Code:
if Grid then Grid.db:SetProfile("nameOfProfile") end
but this throws up an error if Grid isn't loaded. Am I doing it wrong? Or have I misunderstood the whole concept possibly..
  Reply With Quote
01-16-15, 03:28 PM   #2
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,934
I believe using the function IsAddOnLoaded(name) will return true if it and false if it isn't. The true / false may be 0 / -1 or other way round though.
__________________


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
  Reply With Quote
01-16-15, 03:48 PM   #3
Kaitain1977
A Deviate Faerie Dragon
 
Kaitain1977's Avatar
AddOn Compiler - Click to view compilations
Join Date: Jan 2009
Posts: 12
Originally Posted by Xrystal View Post
I believe using the function IsAddOnLoaded(name) will return true if it and false if it isn't. The true / false may be 0 / -1 or other way round though.
ok thanks I'll try that out
  Reply With Quote
01-16-15, 04:13 PM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Kaitain1977 View Post
Code:
if Grid then Grid.db:SetProfile("nameOfProfile") end
Originally Posted by Xrystal View Post
I believe using the function IsAddOnLoaded(name) will return true if it and false if it isn't.
Both of those will have the same problem -- Grid.db is not defined immediately when Grid is defined. If you need to do stuff with AceDB profiles in non-LoD addons, you should wait for the PLAYER_LOGIN event.

If you need to do stuff with profiles in LoD addons (note Grid is not LoD) you may have to wait for the addon's ADDON_LOADED event and then hook whichever of its methods creates the db.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
01-16-15, 08:53 PM   #5
Nimhfree
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 267
Yeah, different addons behave in different ways. If you plan on relying on / detecting another addons abilties/functions you need to figure out how that addon works, when things are initialized, etc. I wish there were clear rules about these things but each addon takes their own view (including my own). What really is horrible is when you work out how something happens, implement your addon to make use of this, and then the addon author of the other addon goes and changes things. :-(
  Reply With Quote
01-16-15, 08:56 PM   #6
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
If you set an addon as an optional dependency in your toc file it will be loaded before yours if it's enabled.
  Reply With Quote
01-16-15, 10:41 PM   #7
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
But this still doesn't solve the OP's problem. Yes, it would ensure that the Grid table would exist, but the db key in that table might not still.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
01-17-15, 05:50 AM   #8
Kaitain1977
A Deviate Faerie Dragon
 
Kaitain1977's Avatar
AddOn Compiler - Click to view compilations
Join Date: Jan 2009
Posts: 12
Ok thanks guys. I think I understand the issues with this now :-) The code I'm using is to be triggered from a /slash command so all the addons should be fully loaded. Perhaps I should have said enabled instead of loaded. What I wanted to script to cover for was people who had switched some of the addons off before they used the slash command to load the profiles. In my installation instructions I say to have ALL the addons loaded, so it's really just to help people who can't read instructions :-)
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Detect if addon is loaded


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off