Get or generate block data||doc135408

September 20, 2022

Format

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

Description

Get the custom block data of the specified coordinates in the map. If there is none, generate an empty table {} and return it.


Precautions

  • If the data for the corresponding block accessed does not exist, an empty table {} is returned.

Parameters

Variable name type Description
pos Vector3 specified location


Value Returned

type Description
variant data sheet


Code Samples

on the server sideglobal script, get the block data of (1, 1, 1) coordinates on the map001 map

local map = World.CurWorld:getMap("map001")
local data = map:getOrCreateBlockData(Lib.v3(1, 1, 1))
if data.sign then                              
   data.sign = true
end