Find an item||doc135681

September 20, 2022


  • The class to which the function belongs:tray


Returns a list of item instances according to the filter function, but when the function returns true, the item instance will enter the list, otherwise it will not enter the list.


Variable name type Description
cmp function Filter function with item instance as parameter

Value Returned

type Description
table A list with the tray slot as the index and the item instance as the value

Code Samples

On the server side of the entity templatemount script, add the registration of this type of entity object tray when adding itemCallback, get the list of items in the tray with the configuration name "item"

Trigger.addHandler(this:cfg(), "SETTLE_ITEM", function(context)
    local entity = context.obj1
    local tray = context.tray
    local items = tray:query_items(function(item)
        if item:cfg().fullName == "myplugin/item" then
            return true
        return false