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:
local animal
local frame = CreateFrame('Frame', 'frameName', parentFrame)
function MyModule:OnEnable()
animal = animal or "dog"
frame:Show()
end
function MyModule:OnDisable()
animal = nil
frame:Hide()
end