Block hit event (ray)||doc135419

September 20, 2022

Format

 BLOCK_HITTED_BY_RAY
  • The class to which the function belongs:Block

Description

Triggers an event when a block is hit by a ray skill.


Context

The context content of the event

name type Description
pos Vector3 the coordinates of the block
obj1 Entity the object instance that emits the ray


Code Samples

on the server sideglobal script, register when the grass block is hit by the ray skillCallback, remove the block

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