View Single Post
01/25/16, 06:20 AM   #3
Terrillyn
AddOn Author - Click to view addons
Join Date: Jan 2016
Posts: 24
Originally Posted by coolmodi View Post
Doesn't that mean you use AWSV to save new changes but copy the data from CharSV (that didn't change) over that every time you reload UI? That would reset it to whatever is in CharSV. But maybe ZO_DeepTableCopy is the other way round, don't know.
the prototype is ZO_DeepTableCopy(source, dest); I have SimpleXPBar.CharSV get overwritten if accountwide is chosen so that the individual characters will have there settings overwritten, this was intended to mitigate the issue of [when you uncheck the accountwide setting you have to redo all the changes you made on each character], though I may just add a button to push current settings to all characters for this purpose.

Originally Posted by coolmodi View Post
Edit: Either way I think it has to be the ZO_DeepTableCopy function, my solution was pretty much the same, just without copying tables around (why would you do that anyways?).

Lua Code:
  1. function GroupDamage:RestoreData()
  2.     self.savedVariablesAw = ZO_SavedVars:NewAccountWide("GroupDamageSavedVariables", defaultVarsVer, nil, defaults)
  3.     self.savedVariablesChar = ZO_SavedVars:New("GroupDamageSavedVariables", defaultVarsVer, nil, defaults)
  4.     self.svars = self.savedVariablesChar
  5.     if self.savedVariablesAw.accountWide then
  6.         self.svars = self.savedVariablesAw
  7.     end
  8. end
  9.  
  10. --the AW checkbox
  11. {
  12.             type = "checkbox",
  13.             name = GetString(SI_GROUPDAMAGE_MENU_ACCWIDESETTINGS),
  14.             getFunc = function() return self.savedVariablesAw.accountWide end,
  15.             setFunc = function() self.savedVariablesAw.accountWide = not self.savedVariablesAw.accountWide ReloadUI() end,
  16.             warning = GetString(SI_GROUPDAMAGE_MENU_RELOADWARN)
  17.         },
  18.  
  19. --a colorpicker, you can use tables for the colors and then unpack(table) to make it alot shorter and easier to use ;)
  20. {
  21.             type = "colorpicker",
  22.             name = GetString(SI_GROUPDAMAGE_MENU_BARSCOLOR),
  23.             getFunc = function() return unpack(self.svars.panelBarsColor) end,
  24.             setFunc = function(r,g,b,a)
  25.                 self.svars.panelBarsColor = {r,g,b,a}
  26.                 self:ResetPanelControls()
  27.             end,
  28.         },
I'll try it like yours, without the deepcopy, I'm still not entirely sure how shallow copying works in Lua yet; I like that trick with using unpack, I wasn't aware of that function. Thanks.
  Reply With Quote