Seems the addon is not using the ZO_SavedVars wrapper for accessing the SV table ResourceRadar_SavedVars.
-> The wrapper is creating the subtables ["default'] and [$AccountWide] e.g. so they are missing because ZO_SavedVars was not used!
Exaplanation:
SavedVars defined as ## SavedVariables in the addon's txt file are just a global table.
So ResourceRadar_SavedVars is a table.
And the addon decided to add the structures like the characterId etc. "manually" to that table instead of using the Zos wrapper for that, called "ZO_SavedVars".
If you want to change the addon's SV table from characterId to accountWide you need to replace each occurence of characterId in there with your accountName (API function: GetDisplayName())
This applies to the code you had copied here, but also to the settings menu and every other file and code where ResourceRadar_SavedVars is currently used with the .character[characterId].
I'd keep the .character subtable in the SV table ResourceRadar_SavedVars, and just add a new subtable .account.
That way you could switch back to characterId SV later. See further down below!
Code now:
Lua Code:
ResourceRadar_SavedVars = ResourceRadar_SavedVars or {}
local characterId = GetCurrentCharacterId()
ResourceRadar_SavedVars.character = ResourceRadar_SavedVars.character or {}
ResourceRadar_SavedVars.character[characterId] = ResourceRadar_SavedVars.character[characterId] or {}
self.currentProfile = ResourceRadar_SavedVars.character[characterId]
Could be changed to:
Lua Code:
ResourceRadar_SavedVars = ResourceRadar_SavedVars or {}
local characterId = GetCurrentCharacterId()
ResourceRadar_SavedVars.character = ResourceRadar_SavedVars.character or {}
ResourceRadar_SavedVars.character[characterId] = ResourceRadar_SavedVars.character[characterId] or {}
--self.currentProfile = ResourceRadar_SavedVars.character[characterId] --Commented as the currentProfile should be used from account data now, see below!
local currentAccount = GetDisplayName()
ResourceRadar_SavedVars.account = ResourceRadar_SavedVars.account or {} --reuses the account subtable or creates an empty one if missing
ResourceRadar_SavedVars.account[currentAccount] = ResourceRadar_SavedVars.account[currentAccount] or {}
self.currentProfile = ResourceRadar_SavedVars.account[currentAccount ]
And after that you need to find EACH code line where currently ResourceRadar_SavedVars.character[characterIdHere] is used and replace it with
ResourceRadar_SavedVars.account[GetDisplayName()] so that the SV table will be read from your account data now.
After 1st login and 1x /reloadui ingame., with that changed SV data subtable .account, you should see the .account table in the SV file in your live/SavedVariables/<addonFolderName>.lua file.
And you can logout then, backup the file and manually copy over your character entry of 1 of your characters to the account["@YourAccountNameHere"] table.
If you have kept the .character subtables:
You could even add a settings menu entry to switch that dynamically via the LibAddonMenu settings.
Like always read the account SV first and if there is saved something like a boolean (true/false) variable savePerCharacter you can switch the SV usage with it.
-> Checkbox in LAM settings of the addon should change ResourceRadar_SavedVars.account[currentAccount].savePerCharacter via it's setFunc and read the same via the getFunc.
At the SV initialization you can read it explicitly then and switch the SV usage:
Lua Code:
local sv -- define that at the top of the file so it's accessible properly within all functions and within the LibAddonMenu settings
--In the EVENT_AD_ON_LOADED callback function:
if ResourceRadar_SavedVars.account[currentAccount].savePerCharacter == true then
--Use character SavedVars
sv = ResourceRadar_SavedVars.character[GetCurrentCharacterId()]
else
--Use account savedVars
sv = ResourceRadar_SavedVars.account[GetDisplayName()]
end
You'd have to change the hardcoded usage of ResourceRadar_SavedVars.account or ResourceRadar_SavedVars.character to use the "sv" variable then, as it will "reference" then either the character or the account SV subtable for your saved data, for reading and writing.