View Single Post
08/11/14, 09:46 PM   #18
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Saved variables is just a table and you can define how its structure should look like.

Default structure is:
Lua Code:
  1. MyAddon_SavedVariables = {
  2.     profile = {
  3.         displayName = {
  4.             characterName = {
  5.                 namespace = {
  6.                     version = 1,
  7.                 },
  8.             },
  9.         },
  10.     },
  11. }

You can define all key names (except of displayName and characterName):
Lua Code:
  1. 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:
  1. local sv, profile
  2. local defaults = {}
  3. defaults.profile = {
  4.     name = "pve",
  5. }
  6. defaults.pve = {
  7.     key1 = true,
  8. }
  9. defaults.pvp = {
  10.     key1 = false,
  11. }
  12.  
  13. EVENT_MANAGER:RegisterForEvent("MyAddon", EVENT_ADD_ON_LOADED,
  14.     function(event, addon)
  15.         if addon ~= "MyAddon" then return end
  16.         EVENT_MANAGER:UnregisterForEvent("MyAddon", event)
  17.  
  18.         profile = ZO_SavedVars:New(MyAddon_SavedVars, 1, nil, defaults.profile)
  19.         sv = ZO_SavedVars:New(MyAddon_SavedVars, 1, nil, defaults[profile.name], profile.name)
  20.     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.

Last edited by Garkin : 08/17/14 at 06:35 AM. Reason: Corrected?
  Reply With Quote