ContainerQuery

Group
Queries
Methods
6
Fields
None

Getting one

bank:search()
player:inventory():search()
player:equipment():search()

Methods

MethodReturnsDescription
ids({ number })ContainerQueryKeep only items whose id is in the list.
named(string)ContainerQueryKeep only items whose whole name matches, ignoring case: | separates alternatives and * is any run of characters, so "Grimy *|Shark"…
containing(string)ContainerQueryKeep only items whose name contains the text, ignoring case: | separates alternatives.
count()numberHow many items survived the filters. Slots, not stack quantities.
first()ItemHandle?The first surviving item in slot order.
collect(){ ItemHandle }Every surviving item, in slot order.

Returned by

MethodReturnsDescription
Bank.searchContainerQueryA query over the bank's contents, live or last-known. An unseen bank reads as empty: cached() ~= nil tells the two apart.
Equipment.searchContainerQueryA query over what is worn.
Inventory.searchContainerQueryOpen a query over the inventory's items.

Method details

named

named: (ContainerQuery, string) -> ContainerQuery

Keep only items whose whole name matches, ignoring case: | separates alternatives and * is any run of characters, so "Grimy *|Shark" is every grimy herb and a shark, and "shark" is not a Raw shark.

name
The name pattern.

containing

containing: (ContainerQuery, string) -> ContainerQuery

Keep only items whose name contains the text, ignoring case: | separates alternatives.

text
The text to look for.
Example
-- Part of a name: any prayer potion, any dose.
local potions = inventory:search():containing("prayer potion"):count()

-- The whole name, ignoring case: only four-dose ones.
local full = inventory:search():named("Prayer potion(4)"):count()

-- Several names: `|` separates them.
local food = inventory:search():named("Shark|Manta ray"):count()

count

count: (ContainerQuery) -> number

How many items survived the filters. Slots, not stack quantities.