Query the number of items||doc135683

September 20, 2022

Format

 tray:count_item_num_by_fullname(fullname) 
  • The class to which the function belongs:tray

Description

Returns the number of items from the inventory based on the item name.


Parameters

Variable name type Description
fullname string Tool placement name


Value Returned

type Description
int Tool quantity


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 total number of item of the new item type in the tray

Trigger.addHandler(this:cfg(), "SETTLE_ITEM", function(context)
    local entity = context.obj1
    local item = context.item
    local tray = context.tray
    local count = tray:count_item_num_by_fullname(item:fullName())     --Get the number of item
    print(count)
end)