View Single Post
04/11/14, 09:38 PM   #9
Xrystal
caritas omnia vincit
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 369
Okay, I've been working on the saved variables some more today so that I can get a way to import data, delete duplicates, wipe whole segments etc but still have the information accessible as normal without the need to log out ( except in the case of importing another file if importing several at a time ).

Anyways, the picture attached shows the output from the following traversal function ( which won't work under normal circumstances so have to pull some strings ).

This function only goes as far as the first useful set of information that is used to write to the saved variables using the table that you set up at the beginning.

EG. Normally I would write something along the lines of table.insert(SVData[zone][item],{ ... etc ... }). I had to set my saved vars to the Data subtable so that I knew when I got to the information I wanted.

Lua Code:
  1. local function CheckSavedVars()
  2.     for default,sv in pairs(XrysGatherer_SavedVariables) do
  3.         ChatMsg:AddMessage("Default: "..tostring(default).." "..tostring(sv).." "..tostring(type(sv)))
  4.         for account,accountv in pairs(sv) do
  5.             ChatMsg:AddMessage("Account: "..tostring(account).." "..tostring(accountv).." "..tostring(type(accountv)))
  6.             for accountWide,acWideV in pairs(accountv) do
  7.                 ChatMsg:AddMessage("AcWide: "..tostring(accountWide).." "..tostring(acWideV).." "..tostring(type(acWideV)))
  8.                 for index,data in pairs(acWideV) do
  9.                     ChatMsg:AddMessage("Data/Version: "..tostring(index).." "..tostring(data).." "..tostring(type(data)))
  10.                     if index == "Data" then
  11.                         for i,v in pairs(data) do
  12.                             ChatMsg:AddMessage("Contents: "..tostring(i).." "..tostring(v).." "..tostring(type(v)))
  13.                         end
  14.                     end
  15.                 end
  16.             end
  17.         end
  18.     end
  19. end

In short the results were along the lines of what I was seeing happening but it is nice to get confirmation in writing.

The SavedVariables table actually stores both the values imported into memory when you first log in and the values added via the SVData table after it is initialised that session. I am assuming the ZO_SavedVars object knows what to do when you want to look at the data via SVData as it has access to both old and new data if accessed directly but you can't traverse it like you can the original table.

The first block of "Data" tables is your existing data and the second block of "Data" tables are your current session data. Handy for those addons that may want to keep track of session records. Yes, it has given me ideas for another feature, in between my work on the map pins.

Just something for your brains to tick over.

The question is whether this knowledge helps me with my current saved variable update problems.

edit:
Ah, now I see why I was getting confused with lack of information before. My harvestHistory extraction routine is automatically grabbing both the full data and the session data, not realising that both loads of data are in the table. It also explains why it is not letting me clear all the data I was expecting when I tell it to clear. It's because the stuff it isn't clearing is the current sessions data. Looks like 0.0.9 will be a little while longer before it's update.

edit2:
Actually after a few logins and reloads between test runs of my debug code and it seems there is no specific order to the data, just that there are multiple blocks of the Account Data table. One for all data ( or just what was loaded ) and one for the current session possibly. Although for some reason it is letting me delete certain data but not all data. Must be something else that decides what gets kept and what doesn't during the session manipulation of the saved variables.

edit3:
Scratch that. Looks like it must have been due to some dodgy account ID due to the import tests I was doing. So more tests to see if I can get the same corruption to happen again.
Attached Thumbnails
Click image for larger version

Name:	Screenshot_20140412_042136.jpg
Views:	809
Size:	646.9 KB
ID:	118  

Last edited by Xrystal : 04/11/14 at 11:15 PM.
  Reply With Quote