get block coordinates||doc135402

September 20, 2022

Format

 Map:getBlockPosInArea(min, max, fullNames)
  • The class to which the function belongs:Map

Description

Returns the coordinates of the blocks with certain block IDs in an area consisting of the smallest and largest coordinates.


Precautions

  • fullNames is an ordered table that holds the configuration names of the blocks that need to be looked up.
  • The min coordinate must be less than the max coordinate, otherwise it returns an empty table nil .
  • The values for each axis of the min and max coordinates must be integers, otherwise unintended consequences will occur.

Parameters

Variable name type Description
min Vector3 Minimum coordinates
max Vector3 maximum coordinate
fullNames table Block Configuration Name Table


Value Returned

type Description
table Coordinate table


Code Samples

on the server sideglobal script, get the coordinate positions of all grass squares within the coordinates (0, 0, 0) to (4, 4, 4)

local map = World.CurWorld:getOrCreateStaticMap("map001")
local blocks = map:getPosArrayWithIdsInArea(Lib.v3(0, 0, 0), Lib.v3(4, 4, 4), {"myplugin/grass"})
for _, pos in pairs(blocks) do
    print("grass pos : " , pos)
end