new item||doc135668

September 20, 2022

Format

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

Description

Create item based on configuration name and quantity


Precautions

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

Parameters

Variable name type Description
fullName string Tool placement name
count int Tool quantity


Value Returned

type Description
Item item instance


Code Samples

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

local item = Item.new("myplugin/testItem", 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