Skip to content

FilterOwnedItemsByItemID

Ghost edited this page Jun 22, 2023 · 3 revisions

Given a list of itemIDs, filters the list and returns a table containing the IDs and ItemLocations of items in the initial list that are present in the player's inventory. Essentially just the built-in ItemUtil.FilterOwnedItems, but is slightly faster.

Usage

local itemIDs = {17, 18, 35557, 209182, 35556};
local ownedItems = LibInventoryHelper.FilterOwnedItemsByItemID(itemIDs);

for _, item in ipairs(ownedItems) do
    print(item.id)
    DevTools_Dump(item.location)
end

Returns:

  • ownedItems: A table keyed by the item's ID pointing to the item's ItemLocation.
ownedItems = {
    [17] = ItemLocation,
}

(yes I know keying by the ItemID is incredibly cursed)

Clone this wiki locally