I am writing a mod, and I'd like it to 'disable' itself when certain conditions are not met (ie player lacks a profession). At least with respect to the 'ace disable' chat command, though I'm nto sure what the actual way of calling that would be from within my addon. Any suggetions?
The "ace disable" command simply calls your addon's :OnDisable() function, if one is present. To disable "disable" your addon, just call :Disable() from some location, which will tell Ace3 to run :OnDisable(). Inside, you should unregister most events, stop any OnUpdates, etc.
In the opposite, generally speaking OnEnable and OnDisable will do the opposite of each other.
It is magically unregistered for events that are registered to the addon using self:RegisterEvent(), however you may have created your own frames with your own registered events, those are the ones you need to manually unregister.
Get the author to use AddonLoader conditionals and install AddonLoader :P
since he is the author of his mod I'd like to see that conversation .)
another way would be to check the profession before creating any frames, registering events and stuff.. and if the player don't have the profession just set your functions to nil..
CallbackHandler "events" have to be unregistered. Hooks have to be unregistered.
Perhaps a rule of thumb is to reverse what you do in OnEnable()
Not necessarily true. If registered via AceEvent and AceHook, those events and hooks are auto unregistered and unhooked via :OnEmbedDisable() which is called by AceAddon when :Disable() is called.
I think you all may be over-complicating this.. Perhaps what he meant was "make the mod NOT load next time" As in, disable it in the Addon list in the Blizzard Char-select screen. Yes, this is possible.
DisableAddOn("TocName") disables whatever, however, it is still loaded until you either reload your interface, or logout,login
I think you all may be over-complicating this.. Perhaps what he meant was "make the mod NOT load next time" As in, disable it in the Addon list in the Blizzard Char-select screen. Yes, this is possible.
DisableAddOn("TocName") disables whatever, however, it is still loaded until you either reload your interface, or logout,login
I kinda doubt that, since his example was "if the character doesn't have a certain profession" which implies, to me, he'd like it to be enabled if that toon ever got the profession. Doing it the way you say, the end-user would have to realize that the addon was permanently disabled and fix the situation to be able to use it when the profession was attained. Most users will not do this, and would probably completely forget the addon was installed since it now does nothing at all.
his example was "if the character doesn't have a certain profession" which implies, to me, he'd like it to be enabled if that toon ever got the profession.
Which is the PERFECT use for AddonLoader!
Seriously I don't get why everyone ignores AL, it's the best thing ever.
To disable "disable" your addon, just call :Disable() from some location, which will tell Ace3 to run :OnDisable().
Actually Xinhuan answered exactly what I was looking for.
The idea is simply the person lacks the profession that this mod is relevant for, and should just run disable on itself. Thank you all for the help with this, much appreciated.
lol, two page thread, wow.
PS wowace community is freaky responsive.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
In the opposite, generally speaking OnEnable and OnDisable will do the opposite of each other.
Perhaps a rule of thumb is to reverse what you do in OnEnable()
since he is the author of his mod I'd like to see that conversation .)
another way would be to check the profession before creating any frames, registering events and stuff.. and if the player don't have the profession just set your functions to nil..
Not necessarily true. If registered via AceEvent and AceHook, those events and hooks are auto unregistered and unhooked via :OnEmbedDisable() which is called by AceAddon when :Disable() is called.
DisableAddOn("TocName") disables whatever, however, it is still loaded until you either reload your interface, or logout,login
I kinda doubt that, since his example was "if the character doesn't have a certain profession" which implies, to me, he'd like it to be enabled if that toon ever got the profession. Doing it the way you say, the end-user would have to realize that the addon was permanently disabled and fix the situation to be able to use it when the profession was attained. Most users will not do this, and would probably completely forget the addon was installed since it now does nothing at all.
Which is the PERFECT use for AddonLoader!
Seriously I don't get why everyone ignores AL, it's the best thing ever.
Definitely. Unless the author forgets to update the TOC due to Blizzard changes...like, you know...MountMe having the condition for level 40...
:D
And then there's always exceptions... like the riding turtle.
Actually Xinhuan answered exactly what I was looking for.
The idea is simply the person lacks the profession that this mod is relevant for, and should just run disable on itself. Thank you all for the help with this, much appreciated.
lol, two page thread, wow.
PS wowace community is freaky responsive.