Saved variables is just a table and you can define how its structure should look like.
Default structure is:
Lua Code:
MyAddon_SavedVariables = {
profile = {
displayName = {
characterName = {
namespace = {
version = 1,
},
},
},
},
}
You can define all key names (except of displayName and characterName):
Lua Code:
local namespaceTable = ZO_SavedVars:New(savedVariableTable, version, namespace, defaults, profile)
And if you don't like this structure, just use MyAddon_SavedVariables as any other table.
A4: What is the use for profiles? You can have for the same account name and character name stored more profiles. I have never used it, but I can imagine that it works this way:
Lua Code:
local sv, profile
local defaults = {}
defaults.profile = {
name = "pve",
}
defaults.pve = {
key1 = true,
}
defaults.pvp = {
key1 = false,
}
EVENT_MANAGER:RegisterForEvent("MyAddon", EVENT_ADD_ON_LOADED,
function(event, addon)
if addon ~= "MyAddon" then return end
EVENT_MANAGER:UnregisterForEvent("MyAddon", event)
profile = ZO_SavedVars:New(MyAddon_SavedVars, 1, nil, defaults.profile)
sv = ZO_SavedVars:New(MyAddon_SavedVars, 1, nil, defaults[profile.name], profile.name)
end)
So just save name of active profile and reload UI.
A5: If you are asking if you can force ZO_SavedVars:New() to use user defined string instead of displayName, it can be done only if you redefine function GetDisplayName() (and GetUnitName(unitTag)), the same way as it does Display Name Fix addon.