touch block event||doc135420

September 20, 2022


  • The class to which the function belongs:Block


The event is fired when the entity object touches the block.


The context content of the event

name type Description
obj1 Entity entity object
pos Vector3 the coordinates of the block

Code Samples

on the server sideglobal script, register when a grass block is touched by a solid objectCallback, remove the block

local cfg = Block.GetNameCfg("myplugin/grass")         --Get the grass block config
Trigger.RegisterHandler(cfg, "BLOCK_TOUCH", function(context)
    local entity = context.obj1
    local pos =  context.pos
    local map =                             --Get the current object location map
    map:removeBlock(pos)                               --Remove block