Thread Tools Display Modes
05/08/14, 01:57 PM   #1
lyravega
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 93
Is there a way to clean the now-unused variables from savedVariables?

At the moment, on initialize, I run a function which sets the old variables to nil, so that they disappear from the savedVariables. Is there a built-in command or something easier that'd do the same job?
  Reply With Quote
05/08/14, 02:44 PM   #2
Xrystal
caritas omnia vincit
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 369
Not that I am aware of. Setting the version number to a different value will wipe the whole file ( or maybe that segment if each segment has it's own version number ) but outside of that I haven't seen anything unless it is one of those hidden ZO functions we haven't seen or identified yet.
  Reply With Quote
05/08/14, 03:04 PM   #3
Vuelhering
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 169
Originally Posted by lyravega View Post
At the moment, on initialize, I run a function which sets the old variables to nil, so that they disappear from the savedVariables. Is there a built-in command or something easier that'd do the same job?
Maybe I'm confused, but why are you saving variables if you set them to nil on initialize?

If they're "released" and become unused, you can set them to nil in the program, afaik.

edit: actually I guess it depends on HOW you're doing it. It will work with one level of indirection like saving the variable SV, then SV.unused = nil. If you try SV=nil, it won't work.
  Reply With Quote
05/08/14, 03:15 PM   #4
zolan
 
zolan's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 11
Originally Posted by lyravega View Post
At the moment, on initialize, I run a function which sets the old variables to nil, so that they disappear from the savedVariables. Is there a built-in command or something easier that'd do the same job?
lyravega,

I think nil-ing them is probably the accepted way of doing that.

You can take a look at any of my "Zolan's ___" addons to see how I deal with changes to my configs without having to reset the config version number.

~Zolan
  Reply With Quote
05/08/14, 05:06 PM   #5
lyravega
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 93
I was using something similar, a command attached to "Reset to Defaults" button on my add-on which was doing something like that. Then I moved it to a function and moved all the old (released) variables to there, and am running that function on initialization.

Guess I'll keep doing something similar.

And to answer a question, I generally change the variable names, as I add/expand the features of my little add-on. What was a boolean variable once becomes an integer, and as a habit I attach bool to the name of my boolean variables, and if I see any integer name ending with bool, that really, REALLY bugs me :P

And the reason I was searching for a simple way to clean stuff up is, to keep the savedVariable lua of my mod tidy.

Last edited by lyravega : 05/08/14 at 05:09 PM.
  Reply With Quote
05/08/14, 05:45 PM   #6
Harven
 
Harven's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 135
I can confirm that niling a variable will erease it from saved variables. I'm niling deleted pins in my custom map pins addon and it's working very well.
  Reply With Quote
05/08/14, 07:10 PM   #7
lyravega
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 93
Yup, yup, a key with a nil value doesn't even exist for lua, so key will be gone from the file as well. I wish there was a command to dump the savedVariables file altogether, it could be useful...
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » Is there a way to clean the now-unused variables from savedVariables?


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off