I dont know either. But I talked with my guildies and they told me that there was an addon that let you do that some time ago. To be honest, I dont know how it happen, but it happen.
Rock, I was thinking on another way to overcome this issue regarding the bags. It's possible to know which bag is open or not using GetBagPageLetTime(), and if store the information regarding the slots to search on a table it will be possible to set segmented fors. But that will mess a lot with the actual code. So, I thought about storing the slots free from each bag into an array and give them that to the for instead the total amount.
So, I came up with this to overcome this issue. This code build an array that enclose which bag is active or not, and from where to look for and where to stop. And then, store every slot of the whole backpack in an array that would be use by your getBagSlots() and haveItem() to override the totalSlots from GetBagCount().
This is a new function that return an array with all the slots available in the backpack.
Code: Select all
function GetBagStatus()
local BagPacks = {
Bag1 = { Active = true, Start = 1, End = 30 },
Bag2 = { Active = true, Start = 31, End = 60 },
Bag3 = { Active = true, Start = 61, End = 90 },
Bag4 = { Active = true, Start = 91, End = 120 },
Bag5 = { Active = true, Start = 121, End = 150 },
Bag6 = { Active = true, Start = 151, End = 180 },
}
local SlotsOpen = {}
for i = 1, 6 do
local isLet, letTime = GetBagPageLetTime( i );
if letTime == -1 then
BagPacks["Bag"..i].Active = false
else
BagPacks["Bag"..i].Active = true
end
if BagPacks["Bag"..i].Active then
for y = BagPacks["Bag"..i].Start, BagPacks["Bag"..i].End do
table.insert( SlotsOpen, y )
end
end
end
return SlotsOpen
end
This is the code for getBagSlots that search on every slot returned by the function above instead of using the totalcount.
Code: Select all
function getBagSlots(itemName, group)
local data = {}
local totalSlots = GetBagStatus()
--local occupiedSlots, totalSlots = GetBagCount()
--for i = 1, totalSlots do
for __,value in ipairs( totalSlots ) do
local item = Item(value)
if item.name == itemName or (item.name ~= "" and itemName == "all") or (type(itemName) == "table" and itemName[item.name]) then
if group then
if not data[item.name] then
data[item.name] = {item}
else
table.insert(data[item.name],item)
end
else
table.insert(data,item)
end
end
end
return data
end
This is the code for haveItem that search on every slot returned by the function GetBagStatus() instead of using the totalcount.
Code: Select all
-- Returns true if item found in bag --
local function haveItem(itemName)
local totalSlots = GetBagStatus()
--local occupiedSlots, totalSlots = GetBagCount()
--for i = 1, totalSlots do
for __, value in ipairs(totalSlots) do
local item = Item(value)
if item.name == itemName then
return true
end
end
return false
end
I test it and it seems to work. Need further testing to see if I didnt mess up.
Thanks in advance.