View Single Post
01/27/16, 06:45 AM   #25
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
Originally Posted by Terrillyn View Post
I tried what you said before votan, and its actually just corrupting the table, even a fresh one.

first we call
Lua Code:
  1. SimpleXPBar.AWSV = ZO_SavedVars:New("SimpleXPBar_Settings", "1", nil, SimpleXPBar.default_settings, nil, nil, '$' .. SimpleXPBar.name)
Use :NewAccountWide. This is just obscuring the meaning.
Also, SV version should be number. Not that it's very useful, but if you ever need to go beyond "9", be prepared for an unpleasant surprise.

Originally Posted by Terrillyn View Post
and this is AWSV
Lua Code:
  1. {
  2.     __index = {
  3.         mysaveddata1,
  4.         mysavedata2,
  5.         version = "1",
  6.     },
  7.     __newindex = function,
  8.     default = table...,
  9.     GetINterfaceForCharacter = function,
  10. }
That looks like a metatable, not AWSV contents.

Originally Posted by Terrillyn View Post
then we call
Lua Code:
  1. SimpleXPBar.CharSV = ZO_SavedVars:New("SimpleXPBar_Settings", "1", nil, SimpleXPBar.AWSV)
Defaults are magic. You never, ever, want to pass something you pulled from SV as defaults for another. Pass raw defaults table that's in addon source.


I'd solve the whole thing in a completely different way, but technically the only thing that's wrong with your original code is that ZO_DeepTableCopy copies metatables and you probably don't want that in this case, as it can mess with ZO_SavedVars magic. So you'll be better off writing your own RawDeepTableCopy. Other than that, you should've focused on the color picker:
Lua Code:
  1. getFunc = function()
  2.         return SimpleXPBar.CurSV.textbar.color.r,
  3.  SimpleXPBar.CurSV.textbar.color.b--[[!!!]],
  4.  SimpleXPBar.CurSV.textbar.color.g--[[!!!]],
  5.  SimpleXPBar.CurSV.textbar.color.a
  6.     end,
  Reply With Quote