View Single Post
04-11-19, 02:17 AM   #2
humfras
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Oct 2009
Posts: 131
Ace expects those 3 functions from its addons.

Most AddOns don't use OnDisable at all but provide it 'just in case'.
If it is not going to be used, you can leave it empty.
Most AddOns simply silence* themselves for specific configurations/specs/instances/encounters but do not disable completely.
*deactivate certain functionalities, unregister certain events etc.

If you disable your AddOn via DisableAddOn, it won't be loaded for the following logins/reload.
Using an AceAddOns OnDisable, you can deactivate said AddOn's functionalities as defined in the function without a reload (hooks and frames persist).

And yes, you can not remove hooks, only with a reload.
But if you need to have an option to ignore a hook, you can add a return, eg
Lua Code:
  1. local runhook = true
  2. hooksecurefunc(func, function(...)
  3.   if not runhook then return end
  4.   -- your code here
  5. end)


see https://www.wowace.com/projects/ace3...etting-started

Code:
Standard methods
AceAddon typically expects your addon to define (typically in your main Lua file) 3 methods that it calls at various points:

function MyAddon:OnInitialize()
  -- Code that you want to run when the addon is first loaded goes here.
end
The OnInitialize() method of your addon object is called by AceAddon when the addon is first loaded by the game client. It's a good time to do things like restore saved settings (see the info on AceConfig for more notes about that).

function MyAddon:OnEnable()
    -- Called when the addon is enabled
end

function MyAddon:OnDisable()
    -- Called when the addon is disabled
end
The OnEnable() and OnDisable() methods of your addon object are called by AceAddon when your addon is enabled/disabled by the user. Unlike OnInitialize(), this may occur multiple times without the entire UI being reloaded.
__________________
Author of VuhDo CursorCastBar OptiTaunt Poisoner RaidMobMarker

Last edited by humfras : 04-11-19 at 02:28 AM.
  Reply With Quote