Thread Tools Display Modes
02/06/24, 01:34 AM   #1
evainefaye
Join Date: Feb 2024
Posts: 1
Refreshing PLAYER_INVENTORY

I'm still fairly new to all this but I've picked up quite a bit by taking apart others plugins, and web searches, that said, I'm a bit stuck right now.

I've been playing with both SHARED_INVENTORY and PLAYER_INVENTORY

I'm able to get SHARED_INVENTORY to do what I need with

SHARED_INVENTORY:GetOrCreateBagCache(BAG_BACKPACK)

then I ran across this little bit from PLAYER INVENTORY, PLAYER_INVENTORY:GenerateListOfVirtualStackedItems(BAG_BACKPACK), which seems to stack my item counts which would be useful for what I'm trying to do, but I can't figure out how to refresh it. I've tried about every refresh command I can find but I end up with nothing. Then just a bit ago it seems that calling this again works, but it doesnt work right away, perhaps there is some kind of a timer cooldown for it? Did I miss something? Been trying to dig through the source code but so far no luck.
  Reply With Quote
02/06/24, 06:50 AM   #2
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,989
At first I'll ask: Describe what your usecase is so we can help better, or tell us what you'd like to achieve.


https://github.com/esoui/esoui/blob/...tory.lua#L2077

The function ZO_InventoryManager:GenerateListOfVirtualStackedItems(inventoryType, predicate, itemIds)
is not stacking your items but generating a list of items of the inventoryType, combining different bagIds for that inventoryType (depending on self.inventories[inventoryType] (where self = object created of ZO_InventoryManager -> PLAYER_INVENTORY [see here: https://github.com/esoui/esoui/blob/...ory.lua#L3174]) -> so PLAYER_INVENTORY.inventories[inventoryType].backingBags table -> bagIds to combine).

The backingBars are defined here, per inventoryType:
https://github.com/esoui/esoui/blob/...ntory.lua#L483
e.g. inventoryBank got 1 bags: the normal bank and the ESO+ subscriber bank:
backingBags = { BAG_BANK, BAG_SUBSCRIBER_BANK },

So you will get a list of all items that are in the different bagIds, e.g. BAG_BACKPACK, BAG_WORN, BAG_VIRTUAL (craftbag)
filtered by the predicate function (if provided).

It will just call this function ZO_InventoryManager:GenerateListOfVirtualStackedItemsFromBag(bagId, predicate, itemIds)
https://github.com/esoui/esoui/blob/...tory.lua#L2090

In the end you got a table itemIds with the items that were found in the bagIds.
It may aslo return an empty table if no backingBags are defined for the inventoryType.

Not sure what your usecase is but this will not stack any items in your inventory!


Edit:
To update the shown inventory list you need to call the inventoryObject's UpdateList() function.
PLAYER_INVENTORY:UpdateList(inventoryType)

LibFilters provides API functions to do so too. If you want to filter items in the inventories/crafting tables etc. then use that library to make it compatible with other addons, and call it's libFilters:RequestUpdate(filterType, delay) function

If you do not need to filter (hide items) anything it's probably easier to do it without that lib

Last edited by Baertram : 02/06/24 at 06:57 AM.
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Refreshing PLAYER_INVENTORY


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off