View Single Post
05/26/14, 06:33 AM   #10
Xrystal
caritas omnia vincit
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 369
Yes I know I'm resurrecting an old thread, but its my own thread and I have resolved the problem I had before ... will mean a data reshuffle in my gatherer addon but I will tie that in with the database site going live.

I finally realised that the secret is to have a multiple level of data in the SVData table.

Lua Code:
  1. local SVDefault = {}
  2. local SVDefaultOptions = {
  3.     Filters = {
  4.         [CRAFTING_TYPE_ALCHEMY] = true,
  5.         [CRAFTING_TYPE_BLACKSMITHING] = true,
  6.         [CRAFTING_TYPE_CLOTHIER] = true,
  7.         [CRAFTING_TYPE_ENCHANTING] = true,
  8.         [CRAFTING_TYPE_PROVISIONING] = true,
  9.         [CRAFTING_TYPE_WOODWORKING] = true,
  10.     },
  11.     Verbose = {
  12.         ["New Node"] = true,
  13.         ["Old Node"] = true,
  14.     },
  15. }
  16. SVData = {
  17.   ["NodeData"] = ZO_SavedVars:NewAccountWide("XRGASavedVariables", 2, "NodeData", SVDefault),
  18.   ["ItemData"] = ZO_SavedVars:NewAccountWide("XRGASavedVariables", 2, "ItemData", SVDefault),
  19.   ["Options"] = ZO_SavedVars:New("XRGASavedVariables",2,"Options",SVDefaultOptions),
  20. }
The above will generate NodeData, ItemData and Options as tables but traversing them doesn't work due to the functions and default tables that are sitting in them as well. The secret, and I am sure most of you figured this out ages ago is to add an extra layer to your data. It seems without knowing it I did it for the options table but where I never needed to traverse it I never noticed the solution till now.

Lua Code:
  1. local SVDefaultData = { NodeData = {}, ItemData = {} }
  2. local SVDefaultOptions = {
  3.     Filters = {
  4.         [CRAFTING_TYPE_ALCHEMY] = true,
  5.         [CRAFTING_TYPE_BLACKSMITHING] = true,
  6.         [CRAFTING_TYPE_CLOTHIER] = true,
  7.         [CRAFTING_TYPE_ENCHANTING] = true,
  8.         [CRAFTING_TYPE_PROVISIONING] = true,
  9.         [CRAFTING_TYPE_WOODWORKING] = true,
  10.     },
  11.     Verbose = {
  12.         ["New Node"] = true,
  13.         ["Old Node"] = true,
  14.     },
  15. }
  16. SVData = {
  17.   ["Data"] = ZO_SavedVars:NewAccountWide("XRGASavedVariables", 2, "Data", SVDefaultData),
  18.   ["Options"] = ZO_SavedVars:New("XRGASavedVariables",2,"Options",SVDefaultOptions),
  19. }
So now, instead of trying to traverse the old NodeData table, I simply use SVData["Data"]["NodeData"] and traverse that. Works great in my test runs so far.
  Reply With Quote