A very old bump for 1st thank you for this feedback
I personnally wrote this :
Lua Code:
-- Our bagcache, because game don't have it in realtime
local tinyBagCache = {
[BAG_BACKPACK] = {},
[BAG_BANK] = {},
}
-- Thanks Merlight & circonian, FindFirstEmptySlotInBag don't refresh in realtime.
local function FindEmptySlotInBag(bagId)
for slotIndex = 0, (GetBagSize(bagId) - 1) do
if not SHARED_INVENTORY.bagCache[bagId][slotIndex] and not tinyBagCache[bagId][slotIndex] then
tinyBagCache[bagId][slotIndex] = true
return slotIndex
end
end
return nil
end
But this function is not the only one to do not update in real time, a second one, more recent got the same problem : GetItemLinkStacks(itemLink)
My solution is :
Lua Code:
-- Our bagcache for qty, because game don't have it in realtime
local qtyBagCache = {}
-- this function returns more info than desired, but it's for the exemple.
local function StackInfoInBag(bagToCheck, slotIdFrom, bagIdFrom, itemLink)
local stackCountBackpack, stackCountBank
if not qtyBagCache[itemLink] then
stackCountBackpack, stackCountBank = GetItemLinkStacks(itemLink) -- Not updated in realtime
qtyBagCache[itemLink] = {}
qtyBagCache[itemLink][BAG_BACKPACK] = stackCountBackpack
qtyBagCache[itemLink][BAG_BANK] = stackCountBank
else
stackCountBackpack = qtyBagCache[itemLink][BAG_BACKPACK]
stackCountBank = qtyBagCache[itemLink][BAG_BANK]
end
d("--------------")
d(stackCountBackpack, stackCountBank)
d("---")
d(GetItemLinkStacks(itemLink))
d("--------------")
local stackSize, maxStack = GetSlotStackSize(bagIdFrom, slotIdFrom)
if bagToCheck == BAG_BACKPACK then
return stackCountBackpack >= maxStack, stackSize, maxStack, stackCountBackpack, stackCountBank
elseif bagToCheck == BAG_BANK then
return stackCountBank >= maxStack, stackSize, maxStack, stackCountBackpack, stackCountBank
end
end
An exemple :
Code:
[00:38:18] --------------
[00:38:18] 672 -- backpackqty with mycache func
[00:38:18] 500 -- bankqty with mycache func
[00:38:18] ---
[00:38:18] 672 -- backpackqty with ZOS func
[00:38:18] 500 -- bankqty with ZOS func
[00:38:18] --------------
[00:38:18] BMR a déplacé 72x [Toile du Vide] en banque <----- my addon moved 72x from bag to bank
[00:38:18] --------------
[00:38:18] 600 -- backpackqty with mycache func
[00:38:18] 572 -- bankqty with mycache func
[00:38:18] ---
[00:38:18] 672 -- backpackqty with ZOS func -- Wrong
[00:38:18] 500 -- bankqty with ZOS func -- Wrong
[00:38:18] --------------
[00:38:18] BMR a déplacé 28x [Toile du Vide] en banque <----- my addon moved 28x from bag to bank (from another stack, approx 1ms after 1st move
[00:38:18] --------------
[00:38:18] 572 -- backpackqty with mycache func
[00:38:18] 600 -- bankqty with mycache func
[00:38:18] ---
[00:38:18] 672 -- backpackqty with ZOS func -- Wrong
[00:38:18] 500 -- bankqty with ZOS func -- Wrong
[00:38:18] --------------