Quantcast
WoWInterface - View Single Post - [AceAddon-3.0] Module doesn't fire OnEnable/OnDisable function
View Single Post
12-31-17, 04:23 PM   #6
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,117
I see you are comparing TukUI/ElvUI code with Ace3 and the game's built-in Lua. No wonder you are confused!
  • Calling the event handler in OnInit does nothing because you haven't registered the event yet. That is done in OnEnable (correct). If you need it right away, then register the event in OnEnable and then call it in OnEnable. Of course that requires the module to be enabled.
  • Outlaw.lua's lines 36-38 are useless because AceEvent already handles that. Either pick AceEvent or handle event script handles yourself; don't mix them.
  • There might be a reason why you have holder hooking events, but wouldn't it be easier to just register directly on M?

For your last question, if you set the default state to disabled, then yes, OnEnable, OnDisable do not run, and I don't think OnInit even fires (but I'm not 100% certain of that).

If you want to see a working code base for how to handle Ace3 modules and events, check out SmartRes2 and SmartRes2_Chat. Both work, although I haven't continued them in quite some time. You will notice I do not follow the Tuk/Elv methodology because that is just too complicated and hard to bug fix. You can find both addons here on Wowinterface and also on Twitch/Curse.
  Reply With Quote