New block item||doc135669

September 20, 2022

Format

 Item.newBlock(fullName, count)
  • The class to which the function belongs:item

Description

Create block item based on configuration name and quantity


Precautions

  • The block item created by this method can generally only be matched withsettle_itemuse

Parameters

Variable name type Description
fullName string Block item configuration name
count int number of blocks


Value Returned

type Description
Item Example of block item


Code Samples

On the server side of the player entity templatemount script, get the player's tray and add block item to the tray

local item = Item.newBlock("myplugin/grass", 1)         --Create item instance
local filterTB = {                                
    Define.TRAY_TYPE.HAND_BAG                  
}
local entityTrays = this:tray()                        
local trayTb = entityTrays:query_trays(filterTB)
for tid, _tray in pairs(trayTb) do
    local slot = _tray.tray:find_free()                 --Get the empty slot in the tray
    _tray.tray:settle_item(slot, item)                  --Add item to tray
end