Before trying to invent the wheel new you may look at this library first:
https://www.esoui.com/downloads/info...SavedVars.html
And this is how SavedVariables work in ESO standard, without a library[
The savedvars are bothing else then a global table with the name you specify in your addon's txt file.
You can access this table directly and change the entries in there.
ZO_SavedVars is only a helper function to assign a "pointer variable" (like myAddonSettings) to this global variable.
Example
You have specified your savedvariables object to be named like this in your addon.txt (manifest) file:
Code:
##SavedVariables: MyAddon_SV
If you want to change the SavedVariables of any character, you can achieve it like this:
I assume you are using server dependent SavedVariables.
-> If not, just strip the first [GetWorldName()] bracket!
Lua Code:
local mySavedVariablesOfCharacterId = MyAddon_SV[GetWorldName()]["Default"][GetDisplayName()][CharacterId]
mySavedVariablesOfCharacterId will have additional contents which you have specified using ZO_SavedVars:Newxxx(). e.g. if you have specified ZO_SavedVars:NewCharacterIdSettings() to use a subtable "settings" you'll have this entry within mySavedVariablesOfCharacterId as well:
mySavedVariablesOfCharacterId["settings"].
[CharacterId] will be the uniqueId of your character.
You can get a list of them like this:
Lua Code:
local chars = {}
local function getCharsOfAccount()
--Get the char name and unique ID for the savedvars
for i = 1, GetNumCharacters() do
--Get name and unique id
--- @return name string,gender [Gender|#Gender],level integer,classId integer,raceId integer,alliance [Alliance|#Alliance],id string,locationId integer
local charName, _, _, classId, _, _, characterId, _ = GetCharacterInfo(i)
--Format the name
charName = zo_strformat(SI_UNIT_NAME, charName)
local charData = {}
charData.id = characterId
charData.name = charName
charData.nameClean = charName
charData.class = classId
chars[characterId] = charData
end
end
If you are using AccountWide SavedvAriables the CharacterId will be a fixed string "$AccountWide".
Additional information about SavedVars:
https://wiki.esoui.com/Circonians_Sa...ables_Tutorial
https://wiki.esoui.com/AddOn_Quick_Questions
https://wiki.esoui.com/Addon_manifest_(.txt)_format
https://www.esoui.com/forums/showthr...SavedVariables