ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Lua/XML Help (https://www.esoui.com/forums/forumdisplay.php?f=175)
-   -   ZO_SavedVars - account vs character behavior? (https://www.esoui.com/forums/showthread.php?t=9364)

Tazmyr 08/30/20 01:19 PM

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

Dolgubon 08/30/20 02:19 PM

Quote:

Originally Posted by Tazmyr (Post 42203)
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.

Baertram 08/30/20 03:30 PM

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.

Tazmyr 08/30/20 10:45 PM

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


All times are GMT -6. The time now is 09:44 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI