Where do i put the
Code:
if (not my_var) then my_var = "default Val" end
|
In your function which is fired on "ADDON_LOADED" or "VARIABLES_LOADED".
The code I generally use for saved variables goes as follows (although I have started mucking about with metatables):
Code:
local addon = CreateFrame("Frame")
addon:RegisterEvent("ADDON_LOADED") --I use "ADDON_LOADED" because the majority of my mods use "AddonLoader".
local function OnEnable(self, event, addon)
if addon ~= "my addon name" then return end
if not AddonDB then
AddonDB = {<defaults here>}
end
self:UnregisterEvent("ADDON_LOADED")
<Register any events you want to register here>
self:SetScript("OnEvent", MyEventHandler)
end
addon:SetScript("OnEvent", OnEnable)
Hope this helps you.