Thread Tools Display Modes
01/09/16, 06:17 PM   #1
vandel212
Join Date: Jan 2016
Posts: 17
Prevent Certain Saved Variables from loading

I have an addon where is saves data outside of the game via saved variable. However once it is saved, I do not want the addon to use it anymore. Is it possible so that when loading addons, it does not load all of the saved variables?
  Reply With Quote
01/09/16, 10:00 PM   #2
Ayantir
 
Ayantir's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 1,019
No, ask to author. Of you're the one, juste rewrite your code and don't use it?
  Reply With Quote
01/10/16, 06:29 AM   #3
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 5,015
After reading and using it you could just erase it by setting the appropriate savedvariables table content to nil.
If I remember right all nil variables will be "removed" on next savedvariables dump.
  Reply With Quote
01/10/16, 04:50 PM   #4
vandel212
Join Date: Jan 2016
Posts: 17
Originally Posted by Baertram View Post
After reading and using it you could just erase it by setting the appropriate savedvariables table content to nil.
If I remember right all nil variables will be "removed" on next savedvariables dump.
Well I still need them to exist in the file, setting them to nil removed that line from the file altogether.
  Reply With Quote
01/11/16, 04:44 AM   #5
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 5,015
I do not want the addon to use it anymore
Ok, I read this sentence as "destroy the info"

If you've loaded the data into the addon and don't want the addon to react on it anymore, why do you still need it then? Could you explain what you are trying to do in detail so we can help you better?

Without knowing the details:

You could either set a flag into the savedvariables for this/these entries as they were loaded the first time properly, and react on the flag afterwards.

Or you could move the content of this savedvariables table to a second savedvariables table (like a backup) and use the 2nd savedvariables table then for your checks against the data that you have loaded before.
If the 1st savedvariables doesn't hold the data you can check the 2nd savedvars and this way you know they were read before already and transferred to 2nd saved vars.

To build different SavedVariables you can either change the version number to different ones (one for your current addon versin and one fixed to 999 e.g.), or just specify a different "key" for the SavedVariables, where the data should be saved:

Lua Code:
  1. local addon.settings = ZO_SavedVars:NewAccountWide(addon.name .. "_Settings", addon.version, "Settings", defaultSettings)
  2.  
  3. local addon.transferedSettings = ZO_SavedVars:NewAccountWide(addon.name .. "_TransferredSettings", addon.version, "TransferredSettings", defaultSettings)

You are able to check the "[TransferredSettings]" array in the SavedVariables <addonName>.lua file then for your "backup settings".
  Reply With Quote
01/15/16, 01:50 AM   #6
vandel212
Join Date: Jan 2016
Posts: 17
Originally Posted by Baertram View Post
If you've loaded the data into the addon and don't want the addon to react on it anymore, why do you still need it then? Could you explain what you are trying to do in detail so we can help you better?
So here is what I am doing. I'm gathering data and then having another application outside of ESO look at this then do some processing. So my workflow thus far is, go in game, do some stuff, have it save all the information, and reload the ui so it actually saves to the file. Then the external program processes the saved variables.

That works as expected. I do not want the external program to process the information again, so I'd like to have it clears out each line of the saved variable file that it processes. The issue is that once the user either reloads the UI or exits the game the lines of the saved var file are entered back in to the file. This would cause the external program to process them again next time. There are less attractive ways of getting around this, like checking to see if it's been processed already based on a unique ID, or forcing the user to shut down ESO before running the external application, but those are clunky ways of doing it. I'd rather be able to delete the line in the lua file without it showing up again and never have to worry about it.

So essentially, I'd like ESO to write the saved variables to the file, then forget they exist so that the external program's edits to the saved variables file won't be overwritten.

Last edited by vandel212 : 01/15/16 at 01:54 AM.
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Prevent Certain Saved Variables from loading


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