get item instance||doc135680

September 20, 2022

Format

 tray:fetch_item(slot) 
  • The class to which the function belongs:tray

Description

Returns the item instance on the specified slot of the tray.


Parameters

Variable name type Description
slot int Tray slot


Value Returned

type Description
Item Item


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 item in slot 1 of the tray, if the item exists, output its fullName

Trigger.addHandler(this:cfg(), "SETTLE_ITEM", function(context)
    local entity = context.obj1
    local tray = context.tray
    local item = tray:fetch_item(1) 
    if item then
        print(item:full_name())
    end
end)