Merge pull request #22 from AssemblerManiac/master

manavortex [02-27-18 - 18:53]
Merge pull request #22 from AssemblerManiac/master

item counts for multiple stacks, no longer doubled (or more)
Filename
IIfA/IIfA.lua
IIfA/IIfADataCollection.lua
diff --git a/IIfA/IIfA.lua b/IIfA/IIfA.lua
index 5f8e4b4..bdada3c 100644
--- a/IIfA/IIfA.lua
+++ b/IIfA/IIfA.lua
@@ -460,17 +460,17 @@ function IIfA:MakeBSI()
 					if bs[idx] == nil then
 						bs[idx] = {}
 					end
-					if nil ~= idx and nil ~= data.bagSlot then
-						for bagSlot, qty in pairs(data.bagSlot) do
-							bs[idx][bagSlot] = itemKey
-						end
-					end
 					if data.bagSlot ~= nil and type(data.bagSlot) ~= "table" then
 						bagSlot = data.bagSlot
 						data.bagSlot = {}
 						data.bagSlot[bagSlot] = data.itemCount
 						data.itemCount = nil
 					end
+					if nil ~= idx and nil ~= data.bagSlot then
+						for bagSlot, qty in pairs(data.bagSlot) do
+							bs[idx][bagSlot] = itemKey
+						end
+					end
 				end
 			end
 		end
diff --git a/IIfA/IIfADataCollection.lua b/IIfA/IIfADataCollection.lua
index 626af64..bbaac23 100644
--- a/IIfA/IIfADataCollection.lua
+++ b/IIfA/IIfADataCollection.lua
@@ -377,6 +377,7 @@ function IIfA:GetItemKey(itemLink)
 	return itemLink
 end

+--[[
 local function getItemCount(bagId, slotId, itemLink)
 	local stackCountBackpack, stackCountBank, stackCountCraftBag, itemCount
 	if bagId > BAG_MAX_VALUE then return 1 end		-- it's furniture because of the out of range id, always count of 1
@@ -396,6 +397,18 @@ local function getItemCount(bagId, slotId, itemLink)
 	-- return 0 if no item count was found, possibly an out of date index to a house container that no longer exists
 	return 0
 end
+--]]
+
+local function getItemCount(bagId, slotId, itemLink)
+	if bagId > BAG_MAX_VALUE then return 1 end		-- it's furniture because of the out of range id, always count of 1
+
+	local _, itemCount =  GetItemInfo(bagId, slotId)
+	if itemCount > 0 then return itemCount end
+
+	-- return 0 if no item count was found, possibly an out of date index to a house container that no longer exists
+	return 0
+end
+

 local function getLocation(bagId)
 	if(bagId == BAG_BACKPACK or bagId == BAG_WORN) then