New tray||doc135688

September 20, 2022


 Tray:new_tray(type, capacity)


Create a new knapsack instance and specify the knapsack capacity. This function is a function of a global class and can be called directly.


Variable name type Description
type Define.TRAY_TYPE Tray Type
capacity int Tray capacity

Value Returned

type Description
tray knapsack instance

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 tray = Tray:new_tray(Define.TRAY_TYPE.BAG)
    local trays = this:tray()
    local tid = trays:add_tray(tray)
    print("tray id:", tid)