ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Lua/XML Help (https://www.esoui.com/forums/forumdisplay.php?f=175)
-   -   Refreshing PLAYER_INVENTORY (https://www.esoui.com/forums/showthread.php?t=10811)

evainefaye 02/06/24 01:34 AM

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.

Baertram 02/06/24 06:50 AM

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


All times are GMT -6. The time now is 12:52 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI