set capacity||doc135673

September 20, 2022

Format

 tray:set_capacity(capacity) 
  • The class to which the function belongs:tray

Description

Set the tray capacity.


Precautions

  • If the maximum capacity of the tray is set, the newly set tray capacity cannot be greater than the maximum capacity, otherwise there will be unexpected consequences
  • The client and server do not synchronize tray capacity data

Parameters

Variable name type Description
capacity int capacity


Code Samples

On the server side of the entity templatemount script, get all the trays of the player, set its tray capacity, and then output the tid and tray capacity of each tray

local entityTrays = this:tray()                        
local trayTb = entityTrays:query_trays(function(tray)   
    return true
 end)
for _, _tray in pairs(trayTb) do
  _tray.tray:set_capacity(1) 
  print(_tray.tid,_tray.tray:capacity())
end