place block event||doc135414

September 20, 2022

Format

 BLOCK_PLACE
  • The class to which the function belongs:Block

Description

The event is fired when a block is placed on the map.


Precautions

  • The placement here refers to the use of block item to place blocks on the scene during the game.

Context

The context content of the event

name type Description
obj1 Object object to place
pos Vector3 the coordinates of the placement
map Map placed map


Code Samples

on the server sideglobal script, register when the grass block is placedCallbackbroadcast tipsGrass blocks are placed

local cfg = Block.GetNameCfg("myplugin/grass")                   --Get the grass block config
Trigger.RegisterHandler(cfg, "BLOCK_PLACE", function(context)
    local placer = context.obj1
    World.CurWorld.SystemNotice(1, "place grass block !", 40)    --Broadcast
end)