add tray||doc135684

September 20, 2022

Format

 EntityTrays:add_tray(tray) 

Description

Add a tray instance to the tray container of the entity object, and return the tray Id. The tray instance can be usedTray:new_tray()create.


Parameters

Variable name type Description
tray tray knapsack instance


Value Returned

type Description
int TrayId


Code Samples

On the server side of the entity templatemount script, add when registering this type of entity to log in to the gameCallback, create a new tray

Trigger.addHandler(this:cfg(), "ENTITY_ENTER", function(context)
    local player = context.obj1
    local trays = player:tray()
    local tray = Tray:new_tray(Define.TRAY_TYPE.BAG)
    local tid = trays:add_tray(tray)
    print("tray id:", tid)
end)