View Single Post
05/01/14, 09:01 AM   #15
Sharlikran
 
Sharlikran's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 666
Lua Code:
  1. function Harvest.saveItem( nodeName, itemName, itemID )
  2.  
  3.     if not Harvest.items.data[itemID] then
  4.         Harvest.items.data[itemID] = {}
  5.         table.insert( Harvest.items.data[itemID], { nodeName, itemName} )
  6.         if Harvest.settings.debug then
  7.             d("Item Data Saved!")
  8.         end
  9.     end
  10.  
  11. end
I completely got rid of Harvest.itemAlreadyFound() and consolidated it to this. My issue was that I was using "Harvest.nodes.data[itemID]" instead of "Harvest.items.data[itemID]"
Lua Code:
  1. ["items"] =
  2.                 {
  3.                     ["data"] =
  4.                     {
  5.                         [27058] =
  6.                         {
  7.                             [1] =
  8.                             {
  9.                                 [2] = [[Red Wheat]],
  10.                                 [1] = [[Barrels]],
  11.                             },
  12.                         },
  13.                         [26976] =
  14.                         {
  15.                             [1] =
  16.                             {
  17.                                 [1] = [[Barrels]],
  18.                                 [2] = [[Lard]],
  19.                             },
  20.                         },
  21.                     },
  22.                     ["version"] = 2,
  23.                 },
It is saving like that. My question is now, how do I reference that? Say I was going to print that out using d(Print something here). Would it be Harvest.items.data[itemID][1].1 or Would it be Harvest.items.data[itemID][1][1] and Harvest.items.data[itemID][1][2]. How do I reference the fields [1] and [2] to print or get at the node name and the item name of the given ItemID?
  Reply With Quote