Get storage block data||doc135403

September 20, 2022

Format

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

Description

Returns a string converted to block data in the specified area in the map. Usually need to cooperateloadBlocksuse.


Precautions

  • The min coordinate must be less than the max coordinate, otherwise the block data cannot be obtained.
  • The values for each axis of the min and max coordinates must be integers, otherwise unintended consequences will occur.
  • If the allBlock parameter is false, only the properties that need to be saved in the block settings in the editor will be converted. At present, the editor does not have this property setting, so usually this parameter is true.

Parameters

Variable name type Description
min Vector3 The smallest point of the specified area within the map
max Vector3 The maximum point of the specified area within the map
allBlock boolean Whether to convert all


Value Returned

type Description
string block data


Code Samples

on the server sideglobal script, convert the (0, 0, 0) coordinates to (5, 5, 5) coordinates in the block into block data

local map = World.CurWorld:getMap("map001")
local data = map:saveBlocks({ x = 0, y = 0, z = 0 }, { x = 5, y = 5, z = 5 }, true)