Block
A Block represents one block in a Shape or MutableShape (like the Map).
A Block can be built with one of the constructors, but it can also be obtained from a Shape or MutableShape with Shape.GetBlock or MutableShape.GetBlock.
⚠️ A Block obtained from an immutable object (like Shape) is in fact read-only, none of its properties can be set in that case.
Constructors
Creates a Block with given color and optional coordinates, { 0, 0, 0 } by default.
Functions
Adds a Block to the Block adjacent to the face passed as parameter. You may provide a Block, a palette index to an existing color in the original Shape's Palette, or any color which will be added automatically to the Shape's Palette if needed.
Returns true if a block was successfully added.
⚠️ Won't work with read-only Blocks.
-- add block when Action2 is triggered Client.Action2 = function() -- cast a ray, see if it touches a block local impact = Player:CastRay() if impact.Block ~= nil then -- add block, adjacent to the face that's been touched impact.Block:AddNeighbor(Color(200, 0, 200), impact.FaceTouched) end end
Removes the Block from its parent MutableShape.
⚠️ Won't work with read-only Blocks.
-- remove block when Action2 is triggered Client.Action2 = function() -- cast a ray and see if it touches a block local impact = Player:CastRay() if impact.Block ~= nil then -- a Block has been found, remove it impact.Block:Remove() end end
Replaces the Block visual properties to be either: identical to the ones from the given Block, to the given Color, or to the ones located at given palette index.
The position remains the same.
⚠️ Only works with blocks from a MutableShape, not Shape.
-- replace block when Action2 is triggered Client.Action2 = function() -- cast a ray and, see if it touches a block local impact = Player:CastRay() if impact.Block ~= nil then -- a Block has been found, replace it impact.Block:Replace(Color(255, 0, 0)) -- make it a red block end end
Properties
Block's coordinates in the Shape or MutableShape model. Block's origin is its bottom-left-down corner.
local b = someShape:GetBlock(1, 2, 3) if b ~= nil then print(b.Coordinates) -- prints "[Number3 X: 1 Y: 2 Z: 3]" end
Shortcut to Coordinates.
Block's coordinates converted in local space, i.e. relative to the Shape's or MutableShape's parent.
local b = someShape:GetBlock(1, 2, 3) if b ~= nil then print(b.LocalPosition) end
Block's Palette index in its original Shape. (first index is 1)
⚠️ This has no effect if the block does not belong to a Shape or MutableShape.
local b = someMutableShape:GetBlock(1, 2, 3) if b ~= nil then -- changes block's properties -- using different palette index b.PaletteIndex = 10 end
Block's coordinates converted in world space.
local b = someShape:GetBlock(1, 2, 3) if b ~= nil then print(b.Position) end