View Single Post
09-07-08, 07:48 PM   #22
kerrang
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Oct 2006
Posts: 109
Carrying on the savedvariables thing...

I have to initialise my SVs at some point - where the user hasn't previously 'saved' them.

All my addons upto now have done this at the highest level - e.g.

Code:
MYSV = ""

function MYVARIABLESLOADEDEVENT ()
  -- do something with MYSV
end
I'd assumed that MYSV is set to "" when the addon is loaded and then to whatever it's been saved to before VARIABLES_LOADED is called - but either way it won't be 'nil' when the addon tries to access it.

What someone suggested here earlier is that what I SHOULD be doing is more like

Code:
function MYVARIABLESLOADEDEVENT ()
  if not MYSV then
     MYSV = ""
  end
  -- do something with MYSV
end
Is that a better way to deal with it?

I ask mainly because I have a VERY rare bug whereby MYSV is being reset to "" by something - and the ONLY place it's reset is at the top of the .LUA file (as in the first example).

Why on EARTH this would happen anytime other than login/reload I've no idea - but as MYSV is never set to anything else, anywhere else - I don't know what else it could be!
  Reply With Quote