01-19-2015, 04:01 PM
Code:
function ItemCount(itemid)
local itemcount = 0
--Look through regular bags first.
for x=0,3 do
local inv = Inventory("type="..tostring(x))
for i, item in pairs(inv) do
if (item.id == itemid) then
itemcount = itemcount + item.count
end
end
end
--Look through equipped items bag.
local inv = Inventory("type=1000")
for i, item in pairs(inv) do
if (item.id == itemid) then
itemcount = itemcount + 1
end
end
--Look through armory bags for off-hand through wrists
for x=3200,3209 do
local inv = Inventory("type="..tostring(x))
for i, item in pairs(inv) do
if (item.id == itemid) then
itemcount = itemcount + 1
end
end
end
--Look through rings armory bag.
local inv = Inventory("type=3300")
for i, item in pairs(inv) do
if (item.id == itemid) then
itemcount = itemcount + 1
end
end
--Look through soulstones armory bag.
local inv = Inventory("type=3400")
for i, item in pairs(inv) do
if (item.id == itemid) then
itemcount = itemcount + 1
end
end
--Look through weapons armory bag.
local inv = Inventory("type=3500")
for i, item in pairs(inv) do
if (item.id == itemid) then
itemcount = itemcount + 1
end
end
--Look through quest/key items bag.
local inv = Inventory("type=2004")
for i, item in pairs(inv) do
if (item.id == itemid) then
itemcount = itemcount + item.count
end
end
return itemcount
end
This is an expanded version I use for misc inventory item counting. For fishing you really only need the first loop, but the main ffxivminion module will use this version (and I believe already uses one with basic inventory counting). You can use the code below to test:
Code:
d(ItemCount(itemid))