Thread Tools Display Modes
Prev Previous Post   Next Post Next
04-25-17, 10:17 PM   #21
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,246
To add to Seerah's post, about local functions, frames, etc: if SmartRes2's core option panel is toggled to disable a module, then AceAddon-3.0 will fire an internal callback for that module called Disable. The reverse is also true for enabling, called Enable. These respectively provide OnDisable and OnEnable to the addon developer. See the example below.

Just like you would for any other Ace3 addon, in your module, you would have functions myModule:OnEnable() and myModule:OnDisable() where you would show or hide frames, clear variables, wipe tables, etc.

SmartRes2 does not need to know what those frames are called, or which variable does what within any module. The module controls all of its internal workings.

Just be careful about using nil on everything. It is better to make sure something exists before you recreate it. The following is a short example of the correct way.
Lua Code:
  1. local animal
  2. local frame = CreateFrame('Frame', 'frameName', parentFrame)
  3.  
  4. function MyModule:OnEnable()
  5.     animal = animal or "dog"
  6.     frame:Show()
  7. end
  8.  
  9. function MyModule:OnDisable()
  10.     animal = nil
  11.     frame:Hide()
  12. end

Last edited by myrroddin : 04-25-17 at 11:24 PM. Reason: clarity and correction
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » Any possible/alternative ways to access SV at the top of the file?


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