Thread Tools Display Modes
08/30/20, 01:19 PM   #1
Tazmyr
AddOn Author - Click to view addons
Join Date: Aug 2020
Posts: 8
ZO_SavedVars - account vs character behavior?

Trying to understand the behavior and interaction between ZO_SavedVars:NewCharacterId() and ZO_SavedVars:NewAccountWide() ...

If I want to offer character-specific saved variables, would I call BOTH functions and then decide which set of variables to actually use?

If I do call BOTH, at save time, does the game save BOTH sets of variables?

Thanks!

Tazmyr
  Reply With Quote
08/30/20, 02:19 PM   #2
Dolgubon
 
Dolgubon's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2016
Posts: 408
Originally Posted by Tazmyr View Post
Trying to understand the behavior and interaction between ZO_SavedVars:NewCharacterId() and ZO_SavedVars:NewAccountWide() ...

If I want to offer character-specific saved variables, would I call BOTH functions and then decide which set of variables to actually use?

If I do call BOTH, at save time, does the game save BOTH sets of variables?

Thanks!

Tazmyr
You'll actually want to call them on add-on loaded. It'll then save automatically when the user logs out or reloadui. If you call both, then both will be saved - they're different tables and don't affect each other

If you just want to offer character specific variables, then you only need the characterID variables. If you plan to do different svaed variable profiles (e.g. writ crafter, you can choose between account wide and character specific) then you'd use both.
  Reply With Quote
08/30/20, 03:30 PM   #3
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,912
If you want to use both you could e.g. use the account wide SavedVariables with the 3rd parameter (if left nil it will use the value "Default" in the SV table) as a speficif table name like "AccountBaseSettings" where you store the SavedVariables save mode (character or account wide) and other base addon settings like the language etc. which should be the same for the account.

And then you'd load the CharacterId or other account wide settings from another table like "Settings", or the "Default" table.


Keep in mind there exist different servers like EU megaserver and NA megaserver, and the public test server PTS.
You can use GetWorldName() to get the name of the actual server and could use this as well in the ZO_SavedVars: ... (AccountWide or CharacterId) function parameter for profile e.g. to save the different server's savedvars below a subtable of the server's name.

The last parameter of ZO_SavedVars:NewAccountWide will be the name of the account the data will be saved to.
If you leave it empty the game will use the function GetDisplayName() which returns your current @AccountName.
But you could also just specify a string like "AllAccounts" or "All" or "Master" or whatever so all the accounts of the player (at a server) will be saved the same way.

Last edited by Baertram : 08/31/20 at 08:35 AM.
  Reply With Quote
08/30/20, 10:45 PM   #4
Tazmyr
AddOn Author - Click to view addons
Join Date: Aug 2020
Posts: 8
Thanks!

Thanks Dolgubon and Baertram! Just what I needed.
I appreciate your time.
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » ZO_SavedVars - account vs character behavior?

Thread Tools
Display Modes

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