View Single Post
05/01/14, 02:18 AM   #12
Sharlikran
 
Sharlikran's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 665
Still having issues creating a new section now. I want a list of item ID numbers, indexed by the itemID.

I declared my save variable table or whatever it's called
Lua Code:
  1. Harvest.items = ZO_SavedVars:NewAccountWide("Harvest_SavedVars", 2, "items", { data = {} } )

This is what I wrote to insert into that table
Lua Code:
  1. function Harvest.saveItem( nodeName, itemName, itemID )
  2.  
  3.     if Harvest.itemAlreadyFound( nodeName, itemName, itemID ) then
  4.         return
  5.     end
  6.  
  7.     if not Harvest.nodes.data[itemID] then
  8.         Harvest.nodes.data[itemID] = {}
  9.     end
  10.  
  11.     if Harvest.settings.debug then
  12.         d("Save data!")
  13.     end
  14.  
  15.     table.insert( Harvest.items.data[itemID], { nodeName, itemName, } )
  16. end

Here is what I expect it to look like:
Lua Code:
  1. HarvestMap_SavedVariables =
  2. {
  3.     ["Default"] =
  4.     {
  5.         ["@Sharlikran"] =
  6.         {
  7.             ["$AccountWide"] =
  8.             {
  9.                 ["items"] =
  10.                 {
  11.                     ["version"] = 2,
  12.                     ["data"] =
  13.                     {
  14.                         [45853] =
  15.                         {
  16.                             [1] = [[Aspect Rune]],
  17.                             [2] = [[Rekuta]],
  18.                         },
  19.                         [45834] =
  20.                         {
  21.                             [1] = [[Essence Rune]],
  22.                             [2] = [[Okoma]],
  23.                         },

This is what it looks like so far
Warning: Spoiler


Here is the routine to check for duplicate itemID numbers.
Lua Code:
  1. function Harvest.itemAlreadyFound( nodeName, itemName, itemID )
  2.  
  3.     if not Harvest.items.data[itemID] then
  4.         return false
  5.     end
  6.  
  7.     local node, item
  8.     node = Harvest.items.data[itemID][1]
  9.     item = Harvest.items.data[itemID][2]
  10.     if (node == nodeName) or (item == itemName) then
  11.         if Harvest.settings.debug then
  12.             d("Node : " .. node .. " Item : " .. item .. " already found!")
  13.         end
  14.         return true
  15.     end
  16.     return false
  17. end

This is the error I am getting. How can I change the syntax to make it work? As you can see in the screen shot I do have the itemID, Item Name, and node name so I can pass those as arguments.
  Reply With Quote