View Single Post
02-17-13, 04:43 PM   #1
Nuggs
A Deviate Faerie Dragon
 
Nuggs's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2010
Posts: 19
Disabling addon from within addon.

Hi peoples,

Currently on one of my addons, it's just for warlocks and monks and what I've been doing for the past two and a half years is just disabling the addon when it's loaded if they aren't on one of the classes the addon is for...

However, I recently noticed(or maybe I knew before but felt it was acceptable at the time) that the first time the addon disables itself using DisableAddon(), it will do so for every character.

This got me thinking, would it be wiser to just make a call something like

Lua Code:
  1. if (select(2,UnitClass("player")) == "WARLOCK") or (select(2,UnitClass("player")) == "MONK") then return; end

at the beginning of the file? I never noticed the pain of DisableAddon until I forgot to disable it on one of my alts and had it get disabled for the characters I didn't want to.

I'm no expert with Lua or the WoW API(I don't really even know Lua, I'm just an old UNIX C guy) so it seems like the call I have right there basically stops the addon from loading in the first place without disabling it.

Is there a benefit to using DisableAddon() over just issuing a return at the beginning of the script? Would I have to do this for every file included in the addon to prevent it from loading?
  Reply With Quote