Reading the other posts I now realize although I offered information, I didn't actually offer a solution:
Warning: Spoiler
Lua Code:
-- Define your character specific saved var table:
characterSpecificSavedVars = ZO_SavedVars:New(savedVariableTable, version , nil, defaults)
-- Define your account wide saved var table:
AccountWideSavedVars = ZO_SavedVars:NewAccountWide(savedVariableTable, version, nil, defaults)
function buildatable(saveType)
local temptable = {}
local numitems = getNumItems()
for item = 1, numitems, 1 do
....
end
--====================--
-- Just change these:
--====================--
if saveType == "Global" then
-- myGlobalVarReference.table = temptable -- this does not work
AccountWideSavedVars.table = temptable
else
-- myPerCharacterVarReference.table = temptable -- this does not work
characterSpecificSavedVars.table = temptable
end
end
One other thing to note is that in these:
Lua Code:
characterSpecificSavedVars = ZO_SavedVars:New(savedVariableTable, version , nil, defaults)
AccountWideSavedVars = ZO_SavedVars:NewAccountWide(savedVariableTable, version, nil, defaults)
You will most likely will NOT want to use your addon version number. The reason is because every time you increase the version number it would wipe out the saved variable table
(it does that automatically when the version number increases). I usually define two version numbers in my addon like:
Lua Code:
local CODE_VERSION = 2.3
local SAVED_VAR_VERSION = 1.2
Then just use them each wherever appropriate.
Lua Code:
characterSpecificSavedVars = ZO_SavedVars:New(savedVariableTable, SAVED_VAR_VERSION, nil, defaults)
AccountWideSavedVars = ZO_SavedVars:NewAccountWide(savedVariableTable, SAVED_VAR_VERSION, nil, defaults)
As the addon version number increases I just change the CODE_VERSION. If the saved variables need to be wiped due to addon changes, then increase the SAVED_VAR_VERSION...and don't define them right next to each other
(one line right after another), you'll end up accidently changing the wrong one by mistake and wiping everyone's saved vars