query tray||doc135686

September 20, 2022




According to the filter function, it returns a list of knapsack instances. When the filter function returns true, it will be added to the list, otherwise it will not be added to the list.


Variable name type Description
filter function filter function with knapsack instance as argument

Value Returned

type Description Format
table The number of ordered groups consisting of a list of elements of the tray id corresponding to the tid and the tray instance corresponding to the tray { { tid = 1, tray = tray }, … }

special usage

  • filter can be of type table, which containsDefine.TRAY_TYPEtype, you can add it to the inventory list

Code Samples

On the server side of the entity templatemount script, the parameter is a function. When the available capacity of the tray is greater than 5, it will be added to the list of tray, and the tid and capacity of each tray will be output.

local entityTrays = this:tray() --Get the container instance of the player's tray instance (more than one tray) 
local trayTb = entityTrays:query_trays(function(tray) --Get the tray according to the filter function and store it in the list in 
 if tray:avail_capacity() > 5 then
 return true
for _, _tray in pairs(trayTb) do

On the server side of the entity templatemount script, the parameter is table, get the two trays of the player TRAY_TYPE.BAG and EQUIP_1, and output the tid and tray capacity of their trays

local filterTB = {
local entityTrays = this:tray()                        
local trayTb = entityTrays:query_trays(filterTB)
for tid, _tray in pairs(trayTb) do