View Single Post
07/07/18, 11:20 AM   #3
Dolgubon
 
Dolgubon's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2016
Posts: 409
Lua Code:
  1. local lastSlot = FindFirstEmptySlotInBag(BAG_BANK) - 1
  2. for index = 0, lastSlot do
  3. ...
  4. end


This is not going to do what you want it to. Bag slots are not consecutive, that is, just because there's an empty slot at slot #10 doesn't mean that slot #50 is also empty. You'll want to do GetBagSize instead if you go this method. This is actually usually my preferred method. It's clean, simple, and easy to remember.

The player bank is actually not one single bag - it's two. BAG_SUBSCRIBER_BANK and BAG_BANK are treated internally as two different bags. As a result, you need to loop over both bags when trying to find stuff, and the StackBag function doesn't really work for the bank.

The Generate function works for combining both using the ZOS functions, but you could also just do something like

Lua Code:
  1. local lastSlot = GetBagSize(BAG_BANK)
  2. for index = 0, lastSlot do
Lua Code:
  1. [color=#E5E5E5] doStuff( BAG_BANK, index)[/color]
  2. [color=#E5E5E5] doStuff(BAG_SUBSCRIBER_BANK, index)
  3. end[/color]



GetBagCache probably shouldn't be used. If the bag cache doesn't exist, you get nothing, so GetOrCreateBagCache is probably always preferable over GetBagCache.

Source code of GetBagCache is:

function ZO_SharedInventoryManager:GetBagCache(bagId)
return self.bagCache[bagId]
end

so SHARED_INVENTORY.bagCache[BAG_BANK] is basically equivalent to GetBagCache, unless an addon changes it.

Finally, one other aspect of GenerateFullSlotData is that you can give it any number of bags, so it would probably be very useful for home storage, and the first parameter is also a filter, so if you want to filter out say anything that is bound, you can do that.

  Reply With Quote