View Single Post
03/07/21, 07:28 AM   #2
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,989
The SV always keep old data until you change the sv version (1 in your case) to something else, or you totally change the SV type (e.g. ZO_SavedVars:NewAccountWide -> :NewCharacterIdSettings).
You are not overwriting them if you just add new valus. This should work pretty well if you do not try to access values too early, or got other errors in your code (before e.g.).

Explanation:
After assigning db = ZO_SavedVars: ... the SV are kept in the game memory (table db) until a reloadui/logout is done. At this time the db entries will be written to the disk live/SavedVariables/<yourAddonsTXTFileName>.lua.

The "default" values are used if the SV are missing (after a fresh install e.g.). Else the data read form the SV lua file will be read into the table db and ONLY those are used. So adding values to the defaults that were not there before is the way to add new settings, correct. They will mix in between the data from the disk (lua file -> read into table db in memory).
But if you try to access the new variables before the ZO_SavedVars are created this might throw an error (liek accessing db.??? before db = ZO_SavedVars:NewAccountWide was done).

btw: If you create new addons think about adding savedvariables support for several servers (live eu, live na, pts) directly from the start (if you think settings of your addon should save differently for the same account on different servers). Could be an advantage or disadvantage.
You can use the last parameter "profile" of ZO_SavedVars:NewAccountWide / ZO_SavedVArs:NewCharacterIdSettings for that purpose by passing in GetWorldName() -> This will retun the server name string, e.g. "NA Megaserver" or "EU Megsaver" or "PTS".
https://wiki.esoui.com/AddOn_Quick_Q...cal_machine.3F


Without getting your total code and the error message with the total details (expand it via the checkbox) we can only assume what is wrong in your code.
Please provide the data.

Last edited by Baertram : 03/07/21 at 11:57 AM.
  Reply With Quote