Set block ID||doc135664

September 20, 2022

Format

 item:set_block_id(id) 
  • The class to which the function belongs:item

Description

Set the block id of the item.


Parameters

Variable name type Description
id int block id


Code Samples

On the server side of the player entity templatemount script, add the error when the registered player switches hand-held itemCallback, when the new item is not empty and is a block item, set its block id to 1

Trigger.addHandler(this:cfg(), "HAND_ITEM_CHANGED", function(context)
    local entity = context.obj1
    local newItem = context.item
    local oldItem = context.oldItem
    if newItem and newItem:is_block() then
      newItem:set_block_id(1)
   end
  end)