View Single Post
11-25-14, 08:23 PM   #16
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
If you're just using one variable per setting (which is a bad plan if you're going to have more than 2-3 settings, but fine for now) you don't need to do any initialization whatsoever. Just read and set the variables and don't worry about whether they exist or not; nil evaluates to false in Lua, so it doesn't matter if they exist or not.

Code:
frame:RegisterEvent("ADDON_LOADED")
frame:SetScript("OnEvent", function(self, event, arg1)
   if event == "ADDON_LOADED" and arg1 == "MyAddonName" then
   window:SetShown(not QWindowHide)
end)
Code:
checkbox:SetScript("OnClick", function(self)
   QWindowHide = self:IsChecked()
   window:SetShown(not QWindowHide)
end)
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote