Originally Posted by Talen-Shei
if saveType == "Global" then
myGlobalVarReference.table = temptable -- this does not work
else
myPerCharacterVarReference.table = temptable -- this also does not work
end
|
|
It looks like Baertram gave you an example of how to use that code. I'm going to throw in a little extra info about saved vars.
I'm not sure what you are trying to accomplish.
- Maybe you don't know how to use the saved variables?
- Or maybe your trying to separate this data from the regular saved variables for some reason?
If you don't know how to use saved variables:
Warning: Spoiler
Lua Code:
-- per character saved variables:
CharacterSpecificSavedVars = ZO_SavedVars:New(savedVariableTable, version, namespace, defaults, profile, displayName, characterName)
-- account-wide saved vars:
AccountWideSavedVars = ZO_SavedVars:NewAccountWide(savedVariableTable, version, namespace, defaults, profile, displayName)
savedVariableTable: name you used in your addon manifest (.txt file):
## SavedVariables: savedVariableTable
version: version number for your saved variables
namespace: an optional namespace (it just creates another separate table
IN your saved var table)
defaults: Default table holding default saved var values
profile: Creates a separate table in the the saved var FILE (not in the saved var table, see below for profile example)
displayName: is the account name
characterName: duh
But unless you want something special you don't need to provide all of those options, just the: savedVariableTable & versionNumber (although a default table with default saved variables will most likely be wanted) anything you don't need just make it nil. If you leave the namespace nil (most addons do) it will use "Default" as the namespace.
Lua Code:
CharacterSpecificSavedVars = ZO_SavedVars:New("JunkItSavedVars", JunkIt.version, nil, JunkItPlayerDefault)
AccountWideSavedVars= ZO_SavedVars:NewAccountWide("JunkItSavedVars", JunkIt.version, nil, JunkItAccountDefault)
With that code you can access the saved variable data with: CharacterSpecificSavedVars & AccountWideSavedVars. Just add items/tables/whatever to them as you wish and the game will handle reading/writing the information to the file:
Lua Code:
CharacterSpecificSavedVars.showMyAddonUI = true
AccountWideSavedVars.allCharactersData = { ....}
Either way my guess is that it is probably saving, just not where you want or your not accessing it correctly afterwords.
Warning: Spoiler
It looks like from your code, the data should be saved here (saved variable file):
Lua Code:
YourAddonSavedVarTable =
{
-- this is what you are saving
["sometTable"] =
{
},
-- This is where all of the saved variable information is when using
-- ZO_SavedVars:New or ZO_SavedVars:NewAccountWide (assuming
-- no special profile was used)
["Default"] = ...
So when your (if you are) using ZO_SavedVars:New or ZO_SavedVars:NewAccountWide later to get the saved vars,
Lua Code:
-- per character saved variables:
SavedVariables = ZO_SavedVars:New("JunkItSavedVars", JunkIt.version, nil, JunkItPlayerDefault)
-- account-wide saved vars:
AccountSavedVariables = ZO_SavedVars:NewAccountWide("JunkItSavedVars", JunkIt.version, nil, JunkItAccountDefault)
the table you saved is not in there, they are separate tables. You would have to load each one of them separately. What it looks like you have done is manually create a separate profile in your saved variable file.
If for some reason your trying to separate this information your trying to save from the rest of the saved variable data, you could add a profile like this:
Warning: Spoiler
Lua Code:
-- separate profile table with per character data:
local profileSavedVariables = ZO_SavedVars:New("TestAddonSavedVars", 3, nil, nil, "MyProfileTable")
-- separate profile table with account-wide data:
local profileAccountSavedVariables = ZO_SavedVars:NewAccountWide("TestAddonSavedVars", 3, nil, nil, "MyProfileTable")
-- and then access it like this:
profileSavedVariables.test = "profile"
profileAccountSavedVariables.test = "profile"
New saved var file with profile table:
Lua Code:
TestAddonSavedVars =
{
["Default"] =
{
-- normal saved var stuff is in here
},
-- this is the separate profile table
-- you created
["MyProfileTable"] =
{
["@xxxxxxx"] =
{
["$AccountWide"] =
{
["version"] = 3,
["test"] = "profile",
},
["Circonian"] =
{
["version"] = 3,
["test"] = "profile",
},
},
},
}