Additive tool||doc135509

September 20, 2022


 Entity:addItem(fullName, count, proc, reason) 
  • The class to which the function belongs:Entity


Additive tool.


Variable name type Description
fullName string Tool placement name
count int quantity
proc function Callback
reason string Add reason, required

callback function parameters

Variable name type Description
item Item item instance


  • This callback function will be called as long as the added item data exists

Code Samples

First, in the Item Library item bar in the editor, useCreate a new item whose ID is the item name

On the server side of the entity templatemount script, add the registration of this type of entity when logging into the gameCallback, add this item to the entity

Trigger.addHandler(this:cfg(), "ENTITY_ENTER", function(context)
    local player = context.obj1
    player:addItem("myplugin/item", 1, nil, "enter")