Hi
I was wondering what the best/most efficient way is to get the content of a bag (e.g. the bank).
When I first started working on an ESO addon, my thinking was to do something like this here. It basically does exactly what I wanted: looping over all items in my bag.
Lua Code:
local lastSlot = FindFirstEmptySlotInBag(BAG_BANK) - 1
for index = 0, lastSlot do
...
end
Some time later however, I noticed that most other devs are relying on "SHARED_INVENTORY". For this I noticed that there are couple of different implementations that are not fully clear to me, when which one should be used. "GetBagCache" sounds pretty good, but since there also is the option to "GetOrCreate...", respectively even "GenerateFullSlotData", I was wondering if there might be instances when the simple "Get..." might return some outdated information? Or even just 'nil'?
Are there any recommendation as to when which implementation is recommended?
Lua Code:
local bagCache = SHARED_INVENTORY:GetBagCache(BAG_BANK)
for index, data in pairs(bagCache) do
...
end
Lua Code:
local bagCache = SHARED_INVENTORY:GetOrCreateBagCache(BAG_BANK)
for index, data in pairs(bagCache) do
...
end
Lua Code:
local bagCache = SHARED_INVENTORY:GenerateFullSlotData(nil, BAG_BANK)
for index, data in pairs(bagCache) do
...
end
Lastly, I assume that the following is just a different implementation of "GetBagCache()" by directly accessing the variable instead of via a function?
Lua Code:
local bagCache = SHARED_INVENTORY.bagCache[BAG_BANK]
for index, data in pairs(bagCache) do
...
end
Thanks a lot in advance =)
Cheers
Klingo