View Single Post
07/28/18, 12:34 AM   #5
Shadowfen
AddOn Author - Click to view addons
Join Date: Jun 2016
Posts: 83
Another example of mixed account-wide and character saved variables would be in ThiefTools. I've got some options which are always character and some which are always account wide, and some which the user can choose between character and account wide (separately for each toon).

The reading of the SavedVars (in ThiefTools.lua) is in onLoaded and once both the accountwide and character options are read, the TT.setOptionsScope chooses for each option section which set of values is used, either character or AW (accountwide).

The SF.defaultMissing() function (called by setOptionsScope) is used to set default values inside the option tables because the ZO_SavedVars:NewAccountWide() and ZO_SavedVars:New() functions only applies the defaults for a sub table only if it is missing - it does not recurse to add in missing subtable values (say from an upgraded option set). SF.defaultMissing() will read through the tables looking for missing keys and adding them from the provided defaults - but leaving the already existing values alone.

Last edited by Shadowfen : 07/28/18 at 12:38 AM.
  Reply With Quote