View Single Post
09-08-08, 02:19 PM   #28
kerrang
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Oct 2006
Posts: 109
Back on the SV thing - taking this code that Mik posted earlier

Code:
local function OnAddonLoaded(self)
 -- Initialize your SV if they don't already exist...
 if not MyModSV then
  MyModSV = {
   showThatSpecialSomething = true,
   anotherSetting = "Yada",
  }
 end

local function OnBagUpdate(container)
 -- Do whatever on your bag update which you can be sure will
 -- not be called until after you SV are loaded or initialized.
 if MyModSV.showThatSpecialSomething then message("It's special!") end
end
Surely, the first time a user runs that addon, they will get an error because MyModSV isn't declared as a global variable - only within a local function???

Once it's been saved and reloaded it will exist - but until that time it doesn't and thus you'll get an error?
  Reply With Quote