block drop||doc135398

September 20, 2022

Format

 Map:checkBlockFall(pos) 
  • The class to which the function belongs:Map

Description

The block at the specified coordinates falls and returns to the coordinate position after falling.


Precautions

  • The block falling condition must meet the block setting in the editor and the block can fall automatically is turned on.
  • The values of each axis of the pos coordinate must be integers, otherwise there will be unintended consequences.

Parameters

Variable name type Description
pos Vector3 coordinate


Value Returned

type Description
Vector3 coordinates after fall


Code Samples

Set the block drop property

on the server sideglobal script, the difference between the y-axis distance of the block with the printed coordinates (0, 50, 0) and the coordinates after it falls

local world = World.CurWorld
local map = world.defaultMap                    
local pos = Lib.v3(0,50,0)                     
map:createBlock(pos, "myplugin/stone")          
local targetPos = map:checkBlockFall(pos)  
print(pos.y - targetPos.y)