WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Saving variables for other addons (https://www.wowinterface.com/forums/showthread.php?t=49584)

VikingP 08-06-14 11:36 AM

Saving variables for other addons
 
Im trying to save settings for other addons, so that i simply can run a script ingame.
Have tested a few ways without any luck.

Any sugestion?

Exampel i whant to add these settings to Bartender savedvariable:

Lua Code:
  1. ["namespaces"] = {
  2.                 ["ActionBars"] = {
  3.                     ["profiles"] = {                       
  4.                         ["Default"] = {
  5.                             ["actionbars"] = {
  6.                                 {
  7.                                     ["showgrid"] = true,
  8.                                     ["version"] = 3,
  9.                                     ["position"] = {
  10.                                         ["y"] = 125,
  11.                                         ["x"] = -265.5,
  12.                                         ["point"] = "BOTTOM",
  13.                                     },
  14.                                     ["padding"] = 8,
  15.                                 }, -- [1]
  16.                                 {
  17.                                     ["showgrid"] = true,
  18.                                     ["version"] = 3,
  19.                                     ["fadeoutalpha"] = 0.3,
  20.                                     ["skin"] = {
  21.                                         ["ID"] = "Default: Buffs",
  22.                                         ["Backdrop"] = false,
  23.                                     },
  24.                                     ["position"] = {
  25.                                         ["y"] = 82,
  26.                                         ["x"] = -265.5,
  27.                                         ["point"] = "BOTTOM",
  28.                                     },
  29.                                     ["padding"] = 8,
  30.                                     ["states"] = {
  31.                                         ["enabled"] = true,
  32.                                         ["default"] = 2,
  33.                                     },
  34.                                 }, -- [2]
  35.                                 {
  36.                                     ["showgrid"] = true,
  37.                                     ["alpha"] = 0.5,
  38.                                     ["version"] = 3,
  39.                                     ["skin"] = {
  40.                                         ["ID"] = "Default: Buffs",
  41.                                         ["Backdrop"] = false,
  42.                                     },
  43.                                     ["position"] = {
  44.                                         ["y"] = 116.5,
  45.                                         ["x"] = 0.4,
  46.                                         ["point"] = "LEFT",
  47.                                         ["scale"] = 0.8,
  48.                                     },
  49.                                     ["padding"] = 9,
  50.                                 }, -- [3]
  51.                                 {
  52.                                     ["showgrid"] = true,
  53.                                     ["alpha"] = 0.5,
  54.                                     ["version"] = 3,
  55.                                     ["skin"] = {
  56.                                         ["ID"] = "Default: Buffs",
  57.                                         ["Backdrop"] = false,
  58.                                     },
  59.                                     ["position"] = {
  60.                                         ["y"] = 82,
  61.                                         ["x"] = 0.4,
  62.                                         ["point"] = "LEFT",
  63.                                         ["scale"] = 0.8,
  64.                                     },
  65.                                     ["padding"] = 9,
  66.                                 }, -- [4]
  67.                                 {
  68.                                     ["showgrid"] = true,
  69.                                     ["rows"] = 2,
  70.                                     ["buttons"] = 6,
  71.                                     ["hidemacrotext"] = true,
  72.                                     ["version"] = 3,
  73.                                     ["skin"] = {
  74.                                         ["ID"] = "Default: Buffs",
  75.                                         ["Backdrop"] = false,
  76.                                     },
  77.                                     ["position"] = {
  78.                                         ["y"] = 113,
  79.                                         ["x"] = 279,
  80.                                         ["point"] = "BOTTOM",
  81.                                         ["scale"] = 0.75,
  82.                                     },
  83.                                     ["padding"] = 3,
  84.                                 }, -- [5]
  85.                                 {
  86.                                     ["showgrid"] = true,
  87.                                     ["rows"] = 12,
  88.                                     ["version"] = 3,
  89.                                     ["skin"] = {
  90.                                         ["ID"] = "Default: Buffs",
  91.                                         ["Backdrop"] = false,
  92.                                     },
  93.                                     ["position"] = {
  94.                                         ["y"] = 201.4,
  95.                                         ["x"] = -35,
  96.                                         ["point"] = "RIGHT",
  97.                                         ["scale"] = 0.76,
  98.                                     },
  99.                                     ["padding"] = 8,
  100.                                 }, -- [6]
  101.                                 {
  102.                                     ["showgrid"] = true,
  103.                                     ["rows"] = 6,
  104.                                     ["enabled"] = true,
  105.                                     ["version"] = 3,
  106.                                     ["skin"] = {
  107.                                         ["ID"] = "Default: Buffs",
  108.                                         ["Backdrop"] = false,
  109.                                     },
  110.                                     ["position"] = {
  111.                                         ["y"] = 144.5,
  112.                                         ["x"] = 351.5,
  113.                                         ["point"] = "CENTER",
  114.                                     },
  115.                                     ["padding"] = 11,
  116.                                     ["visibility"] = {
  117.                                         ["custom"] = false,
  118.                                         ["customdata"] = "[mod:ctrl]show;hide",
  119.                                     },
  120.                                 }, -- [7]
  121.                                 {
  122.                                     ["showgrid"] = true,
  123.                                     ["rows"] = 2,
  124.                                     ["enabled"] = true,
  125.                                     ["buttons"] = 6,
  126.                                     ["hidemacrotext"] = true,
  127.                                     ["version"] = 3,
  128.                                     ["skin"] = {
  129.                                         ["ID"] = "Default: Buffs",
  130.                                         ["Backdrop"] = false,
  131.                                     },
  132.                                     ["position"] = {
  133.                                         ["y"] = 112.5,
  134.                                         ["x"] = -372,
  135.                                         ["point"] = "BOTTOM",
  136.                                         ["scale"] = 0.75,
  137.                                     },
  138.                                     ["padding"] = 3,
  139.                                 }, -- [8]
  140.                                 {
  141.                                     ["showgrid"] = true,
  142.                                     ["rows"] = 6,
  143.                                     ["enabled"] = true,
  144.                                     ["buttons"] = 6,
  145.                                     ["hidemacrotext"] = true,
  146.                                     ["version"] = 3,
  147.                                     ["skin"] = {
  148.                                         ["ID"] = "Default: Buffs",
  149.                                         ["Backdrop"] = false,
  150.                                     },
  151.                                     ["position"] = {
  152.                                         ["y"] = 180,
  153.                                         ["x"] = 624,
  154.                                         ["point"] = "BOTTOM",
  155.                                         ["scale"] = 0.7,
  156.                                     },
  157.                                     ["padding"] = 6,
  158.                                 }, -- [9]
  159.                                 {
  160.                                     ["showgrid"] = true,
  161.                                     ["rows"] = 7,
  162.                                     ["enabled"] = true,
  163.                                     ["buttons"] = 6,
  164.                                     ["hidemacrotext"] = true,
  165.                                     ["version"] = 3,
  166.                                     ["skin"] = {
  167.                                         ["ID"] = "Default: Buffs",
  168.                                         ["Backdrop"] = false,
  169.                                     },
  170.                                     ["position"] = {
  171.                                         ["y"] = 180,
  172.                                         ["x"] = -654.5,
  173.                                         ["point"] = "BOTTOM",
  174.                                         ["scale"] = 0.7,
  175.                                     },
  176.                                     ["padding"] = 6,
  177.                                 }, -- [10]
  178.                             },
  179.                         },
  180.                     },
  181.                 },
  182.                 ["LibDualSpec-1.0"] = {
  183.                 },
  184.                 ["ExtraActionBar"] = {
  185.                     ["profiles"] = {                       
  186.                         ["Default"] = {
  187.                             ["position"] = {
  188.                                 ["y"] = 47,
  189.                                 ["x"] = 5.3,
  190.                                 ["point"] = "CENTER",
  191.                                 ["scale"] = 1.5,
  192.                             },
  193.                             ["version"] = 3,
  194.                             ["skin"] = {
  195.                                 ["ID"] = "Default: Buffs",
  196.                                 ["Backdrop"] = false,
  197.                             },
  198.                         },
  199.                     },
  200.                 },
  201.                 ["MicroMenu"] = {
  202.                     ["profiles"] = {                       
  203.                         ["Default"] = {
  204.                             ["version"] = 3,
  205.                             ["visibility"] = {
  206.                                 ["custom"] = true,
  207.                                 ["customdata"] = "[mod:ctrl-Shift]show;hide",
  208.                             },
  209.                             ["position"] = {
  210.                                 ["y"] = 222,
  211.                                 ["x"] = -306,
  212.                                 ["point"] = "BOTTOMRIGHT",
  213.                             },
  214.                             ["skin"] = {
  215.                                 ["ID"] = "Default: Buffs",
  216.                                 ["Backdrop"] = false,
  217.                             },
  218.                         },
  219.                     },
  220.                 },
  221.                 ["XPBar"] = {
  222.                     ["profiles"] = {                       
  223.                         ["Default"] = {
  224.                             ["position"] = {
  225.                                 ["y"] = 57,
  226.                                 ["x"] = -516,
  227.                                 ["point"] = "BOTTOM",
  228.                             },
  229.                             ["version"] = 3,
  230.                         },
  231.                     },
  232.                 },
  233.                 ["MultiCast"] = {
  234.                     ["profiles"] = {
  235.                         ["Default"] = {
  236.                             ["enabled"] = false,
  237.                             ["version"] = 3,
  238.                             ["position"] = {
  239.                                 ["y"] = 35.00000266710234,
  240.                                 ["x"] = 284.3334044788581,
  241.                                 ["point"] = "BOTTOMLEFT",
  242.                             },
  243.                             ["skin"] = {
  244.                                 ["ID"] = "Default: Buffs",
  245.                                 ["Backdrop"] = false,
  246.                             },
  247.                         },
  248.                     },
  249.                 },
  250.                 ["BlizzardArt"] = {
  251.                     ["profiles"] = {                       
  252.                         ["Default"] = {
  253.                             ["position"] = {
  254.                                 ["y"] = 47,
  255.                                 ["x"] = -512,
  256.                                 ["point"] = "BOTTOM",
  257.                             },
  258.                             ["version"] = 3,
  259.                         },
  260.                     },
  261.                 },
  262.                 ["BagBar"] = {
  263.                     ["profiles"] = {                       
  264.                         ["Default"] = {
  265.                             ["enabled"] = false,
  266.                             ["onebag"] = true,
  267.                             ["position"] = {
  268.                                 ["y"] = 41.75,
  269.                                 ["x"] = 463.5,
  270.                                 ["point"] = "BOTTOM",
  271.                             },
  272.                             ["version"] = 3,
  273.                             ["skin"] = {
  274.                                 ["ID"] = "Default: Buffs",
  275.                                 ["Backdrop"] = false,
  276.                             },
  277.                         },
  278.                     },
  279.                 },
  280.                 ["Vehicle"] = {
  281.                     ["profiles"] = {                       
  282.                         ["Default"] = {
  283.                             ["version"] = 3,
  284.                             ["position"] = {
  285.                                 ["y"] = 24.5,
  286.                                 ["x"] = -170.5,
  287.                                 ["point"] = "RIGHT",
  288.                             },
  289.                             ["skin"] = {
  290.                                 ["ID"] = "Default: Buffs",
  291.                                 ["Backdrop"] = false,
  292.                             },
  293.                         },
  294.                     },
  295.                 },
  296.                 ["StanceBar"] = {
  297.                     ["profiles"] = {                       
  298.                         ["Default"] = {
  299.                             ["version"] = 3,
  300.                             ["position"] = {
  301.                                 ["y"] = 209,
  302.                                 ["x"] = 335,
  303.                                 ["point"] = "BOTTOMLEFT",
  304.                                 ["scale"] = 0.75,
  305.                             },
  306.                             ["padding"] = 7,
  307.                             ["visibility"] = {
  308.                                 ["custom"] = false,
  309.                                 ["possess"] = false,
  310.                                 ["always"] = false,
  311.                                 ["customdata"] = "[mod:ctrl]show;hide",
  312.                                 ["stance"] = {
  313.                                     false, -- [1]
  314.                                 },
  315.                             },
  316.                             ["skin"] = {
  317.                                 ["ID"] = "Default: Buffs",
  318.                                 ["Backdrop"] = false,
  319.                             },
  320.                         },
  321.                     },
  322.                 },
  323.                 ["PetBar"] = {
  324.                     ["profiles"] = {                       
  325.                         ["Default"] = {
  326.                             ["position"] = {
  327.                                 ["y"] = 43.45603810374087,
  328.                                 ["x"] = -133.2001136303006,
  329.                                 ["point"] = "BOTTOM",
  330.                                 ["scale"] = 0.6000000238418579,
  331.                             },
  332.                             ["version"] = 3,
  333.                             ["skin"] = {
  334.                                 ["ID"] = "Default: Buffs",
  335.                                 ["Backdrop"] = false,
  336.                             },
  337.                             ["fadeoutdelay"] = 0.1,
  338.                             ["padding"] = 15,
  339.                             ["visibility"] = {
  340.                                 ["possess"] = false,
  341.                                 ["always"] = false,
  342.                             },
  343.                             ["fadeoutalpha"] = 1,
  344.                         },
  345.                     }
  346.                 },
  347.                 ["RepBar"] = {
  348.                     ["profiles"] = {                       
  349.                         ["Default"] = {
  350.                         ["position"] = {
  351.                             ["y"] = 65,
  352.                             ["x"] = -516,
  353.                             ["point"] = "BOTTOM",
  354.                         },
  355.                         ["version"] = 3,
  356.                         },
  357.                     },
  358.                 },
  359.             },
  360.             ["profiles"] = {
  361.                 ["Default"] = {
  362.                     ["onkeydown"] = true,
  363.                     ["selfcastmodifier"] = false,
  364.                     ["minimapIcon"] = {
  365.                         ["hide"] = true,
  366.                     },
  367.                     ["buttonlock"] = true,
  368.                 },
  369.             },
  370.         }

Phanx 08-06-14 08:43 PM

It might help if you stated what your overall goal is. Are you trying to distribute a premade UI? If so, most people do that by just distributing their WTF folder, and using Reflux to switch to all the right profiles. If you want to avoid making users deal with WTF folder stuff, you could just save your entire saved variable in your addon, and if it's the first time the user has logged in with your addon (check by using your own saved variable), overwrite the "real" variable(s) with yours. You should probably show them a prompt first, so they know to go back up their own saved variables first if they don't want to lose all their settings. You'll also have to reload the UI afterwards.

VikingP 08-06-14 10:13 PM

Quote:

Originally Posted by Phanx (Post 294919)
If you want to avoid making users deal with WTF folder stuff, you could just save your entire saved variable in your addon, and if it's the first time the user has logged in with your addon (check by using your own saved variable), overwrite the "real" variable(s) with yours. You should probably show them a prompt first, so they know to go back up their own saved variables first if they don't want to lose all their settings. You'll also have to reload the UI afterwards.

Thats what im trying todo.

Like when they start up first time there will be a popup for adding the settings. Like the above settings.
I have tryed different ways to add the settings above to Bartender4 savedvariables, but i have limited skills around lua so if some could help me with a example.

Phanx 08-06-14 11:26 PM

Just overwrite the entire variable with your own. For example, if the Bartender4 saved variable is called Bartender4DB (look in its TOC file) then you would just do:

Code:

Bartender4DB = {
    -- your table contents here, copied from your saved variables file
}
ReloadUI()

Note that you cannot do this before Bartender4 has loaded. You should wait until the PLAYER_LOGIN event fires. Also, you cannot reload the UI without user interaction, so the whole thing should be tied to a prompt, eg. "This looks like your first time loading SuperAwesomeUI. Would you like to apply all the settings and reload your UI? Yes/No".

If you need some examples, go look at some UI packs that already do this, such as Mayron UI.

p3lim 08-06-14 11:35 PM

Another example, I do this to load cvars in my "random tools"-addon:

https://github.com/p3lim-wow/Inomena....lua#L175-L189

VikingP 08-07-14 01:25 AM

Thanks for the help so far, both tips worked fine.

So i made a code like this:
Lua Code:
  1. local function InstallMBF()
  2. MBFDB = {
  3.     ["profiles"] = {
  4.         ["Default"] = {
  5.             ["ButtonOverride"] = {
  6.                 [11] = "QueueStatusMinimapButton",
  7.             },
  8.             ["columns_or_rows"] = 4,
  9.             ["locked"] = true,
  10.             ["currentMinimapIcon"] = "QueueStatusMinimapButtonIcon",
  11.             ["mbfHidden"] = true,
  12.             ["GrowUp"] = false,
  13.             ["currentButtonOverride"] = "QueueStatusMinimapButton",
  14.             ["minimapButton"] = {
  15.                 ["minimapPos"] = 192.7577142010699,
  16.             },
  17.             ["mbfAnchor"] = "TOPLEFT",
  18.             ["MBF_FrameLocation"] = {
  19.                 "TOPLEFT", -- [1]
  20.                 nil, -- [2]
  21.                 -172.2963331240912, -- [3]
  22.                 -223.7184393402793, -- [4]
  23.             },
  24.             ["currentChild"] = "LibDBIcon10_KLE",
  25.             ["colorLocked"] = "All",
  26.             ["MinimapIcons"] = {
  27.                 [14] = "Compass",
  28.                 [17] = "ArchyMinimap",
  29.                 [18] = "QueueStatusMinimapButtonIcon",
  30.             },
  31.             ["currentTexture"] = "simple Square",
  32.             ["customChildren"] = {
  33.                 "MinimapButtonFrameDragButton", -- [1]
  34.                 "MiniMapMailFrameDisabled", -- [2]
  35.                 "LibDBIcon10_MrPlowLDB", -- [3]
  36.                 "LibDBIcon10_Bartender4", -- [4]
  37.                 "DBMMinimapButton", -- [5]
  38.                 "LibDBIcon10_PitBull4", -- [6]
  39.                 "LibDBIcon10_Broker_Auditor", -- [7]
  40.                 "LibDBIcon10_TravelAgent", -- [8]
  41.                 "LibDBIcon10_Omen", -- [9]
  42.                 "LibDBIcon10_Skada", -- [10]
  43.                 "tdpsButtonFrame", -- [11]
  44.                 "LibDBIcon10_DXE", -- [12]
  45.                 "LibDBIcon10_Broker_Portals", -- [13]
  46.                 "ZygorGuidesViewerMapIcon", -- [14]
  47.                 "LibDBIcon10_BugSack", -- [15]
  48.                 "FuBarPluginAtlasLootFuFrameMinimapButton", -- [16]
  49.                 "OutfitterMinimapButton", -- [17]
  50.                 "VuhDoMinimapButton", -- [18]
  51.                 "LibDBIcon10_MorgDKP2", -- [19]
  52.                 "MageNug_MinimapFrame", -- [20]
  53.                 "LibDBIcon10_Broker_Calendar", -- [21]
  54.                 "BT_Minimapbtn", -- [22]
  55.                 "FuBarPluginBig BrotherFrameMinimapButton", -- [23]
  56.                 "LibDBIcon10_ElkGuild", -- [24]
  57.                 "RA_MinimapButton", -- [25]
  58.                 "Minimalist_Map", -- [26]
  59.                 "LibDBIcon10_WoWProIcon", -- [27]
  60.                 "LibDBIcon10_AtlasLoot", -- [28]
  61.                 "LibDBIcon10_ArchyLDB", -- [29]
  62.                 "ArchyMinimap_POI1", -- [30]
  63.                 "ArchyMinimap_POI2", -- [31]
  64.                 "ArchyMinimap_POI3", -- [32]
  65.                 "ArchyMinimap_POI4", -- [33]
  66.                 "ArchyMinimap_POI5", -- [34]
  67.                 "ArchyMinimap_POI6", -- [35]
  68.                 "ArchyMinimap_POI7", -- [36]
  69.                 "ArchyMinimap_POI8", -- [37]
  70.                 "ArchyMinimap_POI9", -- [38]
  71.                 "ArchyMinimap_POI10", -- [39]
  72.                 "ArchyMinimap_POI11", -- [40]
  73.                 "ArchyMinimap_POI12", -- [41]
  74.                 "ArchyMinimap_POI13", -- [42]
  75.                 "ArchyMinimap_POI14", -- [43]
  76.                 "PS_MinimapButton", -- [44]
  77.                 "RBSMinimapButton", -- [45]
  78.                 "LibDBIcon10_BigWigs", -- [46]
  79.                 "kgPanel7", -- [47]
  80.                 "TenTonHammer_MinimapButton", -- [48]
  81.                 "LibDBIcon10_KLE", -- [49]
  82.                 "Compass", -- [50]
  83.                 "LibDBIcon10_MBF", -- [51]
  84.                 "LibDBIcon10_Archy", -- [52]
  85.                 "LibDBIcon10_TradeSkillMaster", -- [53]
  86.                 "bUnitFrames_MinimapButton", -- [54]
  87.                 "LibDBIcon10_Masque", -- [55]
  88.                 "QueueStatusMinimapButton", -- [56]
  89.                 "HealBot_ButtonFrame", -- [57]
  90.                 "MMHolder", -- [58]
  91.                 "LeftMiniPanel", -- [59]
  92.                 "RightMiniPanel", -- [60]
  93.             },
  94.             ["padding"] = 3,
  95.         },
  96.     },
  97. }  
  98. ReloadUI()
  99. end
  100.  
  101. local function Decline()
  102.     print('|cffff6000Minimap Button Frame:|r Settings not initialized, you can do so later with /settingsmbf')
  103. end
  104.  
  105. StaticPopupDialogs.INSTALL_MBF = {
  106.     text = "Setup MBF",
  107.     button1 = ACCEPT,
  108.     button2 = CANCEL,
  109.     OnAccept = InstallMBF,
  110.     OnCancel = Decline,
  111.     timeout = 0,
  112.     whileDead = 1,
  113.     hideOnEscape = false,
  114.     preferredIndex = 5,
  115. }
  116.  
  117. SLASH_CONFIGURE1 = "/settingsmbf"
  118. SlashCmdList.CONFIGURE = function() StaticPopup_Show("INSTALL_MBF") end

And that works just fine. I also made one for Bartender. But bartender have default profile set to username. Is there a way i can make it switch to the profile i created (default)?

I also did ran into another problem with Masque. Toc says it's MasqueDB and the savedvariable also confirms this, but using the same as above (with MasqueDB = { ) doesn't work. Any tip?

Phanx 08-07-14 02:05 AM

Quote:

Originally Posted by VikingP (Post 294932)
But bartender have default profile set to username. Is there a way i can make it switch to the profile i created (default)?

See the addon Reflux for an example of switching other addons to specific profiles.

Quote:

Originally Posted by VikingP (Post 294932)
I also did ran into another problem with Masque. Toc says it's MasqueDB and the savedvariable also confirms this, but using the same as above (with MasqueDB = { ) doesn't work. Any tip?

Generally just saying something "doesn't work" is useless, as it gives us absolutely nothing to go on, but this technique probably won't be very helpful for Masque, as the structure of its saved variable depends on which addons the user has installed, which may not just be the ones in your UI pack. You're probably better off just calling the appropriate functions to simulate the user changing the global skin settings themselves.

VikingP 08-07-14 11:04 AM

Thanks for the help. I got it all to work :banana:


All times are GMT -6. The time now is 05:42 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI