Shape

Associated namespace: sm.shape

A userdata object representing a shape in the game.

Values:

Functions:

Operations:

OperationDescription
Shape == ShapeChecks if two instances of Shape refer to the same Shape.

at Vec3

Get:

Returns the direction of a shape's front side.

The direction is affected by the shape's rotation in the world.


body Body

Get:

Returns the Body a shape is part of.


buildable boolean

Get:

Check if a shape is buildable


buoyancy number

Get:

Returns the buoyancy multiplier of a shape.


color Color

Get:

Returns the color of a shape.

Set:

Server only

Sets the color of a shape. This is similar to coloring with the Paint Tool.


connectable boolean

Get:

Check if a shape is connectable


convertableToDynamic boolean

Get:

Check if a shape is convertible to dynamic form


destructable boolean

Get:

Check if a shape is destructable.


erasable boolean

Get:

Check if a shape is erasable.


id integer

Get:

Returns the id of a shape.


interactable Interactable

Get:

Returns the Interactable of a shape, if one exists. Otherwise the function will return nil.


isBlock boolean

Get:

Return true if a shape is a basicmaterial


liftable boolean

Get:

Check if a shape is liftable


localPosition Vec3

Get:

Returns the local grid postition of a shape.


localRotation Quat

Get:

Returns the local rotation of a shape.


mass number

Get:

Returns the mass of a shape.


material string

Get:

Returns the material of a shape.


materialId integer

Get:

Returns the material id of a shape.


paintable boolean

Get:

Check if a shape is paintable


right Vec3

Get:

Returns the direction of a shape's right side.

The direction is affected by the shape's rotation in the world.


stackedAmount integer

Get:

Return the amount that is stacked in the shape

Set:

Server only

Set the amount that is stacked in the shape


stackedItem Uuid

Get:

Return the item Uuid that is stacked in the shape

Set:

Server only

Set the item Uuid that is stacked in the shape


up Vec3

Get:

Returns the direction of a shape's top side.

The direction is affected by the shape's rotation in the world.


usable boolean

Get:

Check if a shape is interactable


uuid Uuid

Get:

Returns the uuid string unique to a shape/block type.


velocity Vec3

Get:

Returns the linear velocity of a shape.


worldPosition Vec3

Get:

Returns the world position of a shape.


worldRotation Quat

Get:

Returns the world rotation of a shape.


xAxis Vec3

Get:

Returns the local x-axis vector of a shape.


yAxis Vec3

Get:

Returns the local y-axis vector of a shape.


zAxis Vec3

Get:

Returns the local z-axis vector of a shape.


createJoint(shape, uuid, position, direction)

Server only

Create a new joint

Parameters:

TypeNameDescription
ShapeshapeThe host shape.
UuiduuidThe uuid of the joint.
Vec3positionThe joint's grid position.
Vec3directionThe joint's normal direction.

Returns:

TypeDescription
Joint The created joint.

destroyBlock(shape, position, size=nil, attackLevel=0)

Server only

Destroy a block.

Parameters:

TypeNameDescription
ShapeshapeThe block shape.
Vec3positionThe local position of the removal box corner.
Vec3size=nilThe size of the removal box. Defaults to 1x1x1 (Optional)
integerattackLevel=0Determines which quality level of block the attack can destroy. Setting it to 0 (default) will destroy any block.

destroyPart(shape, attackLevel)

Server only

Destroy a part

Parameters:

TypeNameDescription
ShapeshapeThe part.
integerattackLevelDetermines which quality level of parts the attack can destroy. Setting it to 0 (default) will destroy any part.

destroyShape(shape, attackLevel)

Server only

Destroy a shape

Parameters:

TypeNameDescription
ShapeshapeThe shape.
integerattackLevelDetermines which quality level of shape the attack can destroy. Setting it to 0 (default) will destroy any shape.

getAt(shape)

Returns the direction of a shape's front side.

The direction is affected by the shape's rotation in the world.

Parameters:

TypeNameDescription
ShapeshapeThe shape.

Returns:

TypeDescription
Vec3The shape's at-axis.

getBody(shape)

Returns the Body a shape is part of.

Parameters:

TypeNameDescription
ShapeshapeThe shape.

Returns:

TypeDescription
BodyThe body which the shape is part of.

getBoundingBox(shape)

Returns the bounding box of a shape – the dimensions that a shape occupies when building.

Parameters:

TypeNameDescription
ShapeshapeThe shape.

Returns:

TypeDescription
Vec3The size of the shape's bounding box.

getBuoyancy(shape)

Returns the buoyancy multiplier of a shape.

Parameters:

TypeNameDescription
ShapeshapeThe shape.

Returns:

TypeDescription
numberThe buoyancy multiplier.

getClosestBlockLocalPosition(shape, position)

Transform a world position to the closest block's local position in a shape.

Parameters:

TypeNameDescription
ShapeshapeThe block shape.
Vec3positionThe world position.

Returns:

TypeDescription
Vec3The closest position.

getColor(shape)

Returns the color of a shape.

Parameters:

TypeNameDescription
ShapeshapeThe shape.

Returns:

TypeDescription
ColorThe shape's color.

getId(shape)

Returns the id of a shape.

Parameters:

TypeNameDescription
ShapeshapeThe shape.

Returns:

TypeDescription
integerThe shape's id.

getInteractable(shape)

Returns the Interactable of a shape, if one exists. Otherwise the function will return nil.

Parameters:

TypeNameDescription
ShapeshapeThe shape.

Returns:

TypeDescription
InteractableThe interactable belonging to the shape.

getInterpolatedAt(shape)

Returns the interpolated direction of a shape's front side.

The direction is affected by the shape's rotation in the world.

Parameters:

TypeNameDescription
ShapeshapeThe shape.

Returns:

TypeDescription
Vec3The shape's interpolated at-axis.

getInterpolatedRight(shape)

Returns the interpolated direction of a shape's right side.

The direction is affected by the shape's rotation in the world.

Parameters:

TypeNameDescription
ShapeshapeThe shape.

Returns:

TypeDescription
Vec3The shape's interpolated right-axis.

getInterpolatedUp(shape)

Returns the interpolated direction of a shape's top side.

The direction is affected by the shape's rotation in the world.

Parameters:

TypeNameDescription
ShapeshapeThe shape.

Returns:

TypeDescription
Vec3The shape's interpolated up-axis.

getInterpolatedWorldPosition(shape)

Returns the interpolated world position of a shape.

Parameters:

TypeNameDescription
ShapeshapeThe shape.

Returns:

TypeDescription
Vec3The shape's interpolated world position.

getIsHarvest(The)

Return whether the shape uuid belongs to a harvest shape

Parameters:

TypeNameDescription
UuidTheshape uuid.

Returns:

TypeDescription
booleanTrue if the shape is harvestable.

getIsStackable(The)

Return whether the shape uuid belongs to a stackable shape

Parameters:

TypeNameDescription
UuidTheshape uuid.

Returns:

TypeDescription
booleanTrue if the shape is stackable.

getJoints(shape, onlyChildJoints=true, onlySubshapes=false)

Returns a table of all joints that are attached to the shape.

Will return all attached joints when onlyChildJoints is set to false.

Will only get the joints which are subshapes to the shape when onlySubshapes is set to true.

Parameters:

TypeNameDescription
ShapeshapeThe shape.
booleanonlyChildJoints=trueFilters what joints to return. Defaults to true (Optional)
booleanonlySubshapes=falseOnly get the joints which are subshapes to the shape. Defaults to false (Optional)

Returns:

TypeDescription
tableThe table of joints attached to the shape. {Joint, ..}

getLocalPosition(shape)

Returns the local grid postition of a shape.

Parameters:

TypeNameDescription
ShapeshapeThe shape.

Returns:

TypeDescription
Vec3The shape's local position.

getLocalRotation(shape)

Returns the local rotation of a shape.

Parameters:

TypeNameDescription
ShapeshapeThe shape.

Returns:

TypeDescription
QuatThe shape's local rotation.

getMass(shape)

Returns the mass of a shape.

Parameters:

TypeNameDescription
ShapeshapeThe shape.

Returns:

TypeDescription
numberThe shape's mass.

getMaterial(shape)

Returns the material of a shape.

Parameters:

TypeNameDescription
ShapeshapeThe shape.

Returns:

TypeDescription
stringThe shape's material.

getMaterialId(shape)

Returns the material id of a shape.

Parameters:

TypeNameDescription
ShapeshapeThe shape.

Returns:

TypeDescription
integerThe shape's material id.

getNeighbours(shape)

Server only

Returns a table of shapes which are neighbours to the shape

Parameters:

TypeNameDescription
ShapeshapeThe shape.

Returns:

TypeDescription
tabletable of shapes. {Shape, ..}

getPipedNeighbours(shape)

Server only

Returns a table of shapes which are neighbours connected with pipes to the shape

Parameters:

TypeNameDescription
ShapeshapeThe shape.

Returns:

TypeDescription
tabletable of shapes. {Shape, ..}

getRight(shape)

Returns the direction of a shape's right side.

The direction is affected by the shape's rotation in the world.

Parameters:

TypeNameDescription
ShapeshapeThe shape.

Returns:

TypeDescription
Vec3The shape's right-axis.

getShapeUuid(shape)

Returns the uuid string unique to a shape/block type.

Parameters:

TypeNameDescription
ShapeshapeThe shape.

Returns:

TypeDescription
UuidThe shape's uuid.

getSticky(shape)

Returns the sticky directions of the shape for positive xyz and negative xyz.

A value of 1 means that the direction is sticky and a value of 0 means that the direction is not sticky.

Parameters:

TypeNameDescription
ShapeshapeThe shape.

Returns:

TypeDescription
{Vec3,Vec3}The negative xyz sticky and the positive xyz sticky.

getUp(shape)

Returns the direction of a shape's top side.

The direction is affected by the shape's rotation in the world.

Parameters:

TypeNameDescription
ShapeshapeThe shape.

Returns:

TypeDescription
Vec3The shape's up-axis.

getVelocity(shape)

Returns the linear velocity of a shape.

Parameters:

TypeNameDescription
ShapeshapeThe shape.

Returns:

TypeDescription
Vec3The shape's linear velocity.

getWorldPosition(shape)

Returns the world position of a shape.

Parameters:

TypeNameDescription
ShapeshapeThe shape.

Returns:

TypeDescription
Vec3The shape's world position.

getWorldRotation(shape)

Returns the world rotation of a shape.

Parameters:

TypeNameDescription
ShapeshapeThe shape.

Returns:

TypeDescription
QuatThe shape's world rotation.

getXAxis(shape)

Returns the local x-axis vector of a shape.

Parameters:

TypeNameDescription
ShapeshapeThe shape.

Returns:

TypeDescription
Vec3The shape's x-axis.

getYAxis(shape)

Returns the local y-axis vector of a shape.

Parameters:

TypeNameDescription
ShapeshapeThe shape.

Returns:

TypeDescription
Vec3The shape's y-axis.

getZAxis(shape)

Returns the local z-axis vector of a shape.

Parameters:

TypeNameDescription
ShapeshapeThe shape.

Returns:

TypeDescription
Vec3The shape's z-axis.

replaceShape(shape, uuid)

Server only

Creates a new Shape from Uuid to replace the given Shape.

Parameters:

TypeNameDescription
ShapeshapeThe shape.
UuiduuidThe uuid of the new shape.

setColor(shape, color)

Server only

Sets the color of a shape. This is similar to coloring with the Paint Tool.

Parameters:

TypeNameDescription
ShapeshapeThe shape.
ColorcolorThe color.

shapeExists(shape)

Deprecated:

use sm.exists

Return true if a shape exists.

Parameters:

TypeNameDescription
ShapeshapeThe shape.

Returns:

TypeDescription
booleanWhether the shape exists.

shapesInSphere(center, radius)

Returns a table of all shapes colliding with a given sphere.

Parameters:

TypeNameDescription
Vec3centerThe center position of the sphere.
numberradiusThe radius of the sphere.

Returns:

TypeDescription
tableThe table of found shapes. {Shape, ..}

transformDirection(shape, vector)

Transform a world direction to the local shape transform.

Parameters:

TypeNameDescription
ShapeshapeThe shape.
Vec3vectorThe untransformed direction.

Returns:

TypeDescription
Vec3The transformed direction.

transformLocalPoint(shape, vector)

Transform a local point to world space.

local worldPos = self.shape:transformLocalPoint( localPos )

Parameters:

TypeNameDescription
ShapeshapeThe shape.
Vec3vectorThe local point.

Returns:

TypeDescription
Vec3The world point.

transformPoint(shape, vector)

Transform a world point to the local shape transform.

local localPos = self.shape:transformPoint( worldPos )

Parameters:

TypeNameDescription
ShapeshapeThe shape.
Vec3vectorThe world point.

Returns:

TypeDescription
Vec3The local point.

transformRotation(shape, quat)

Transform a world rotation to the local shape transform.

local worldUp = sm.vec3.new( 0, 0, 1 )
local worldRot = sm.vec3.getRotation( worldUp, worldDir )
local localRot = self.shape:transformRotation( worldRot )

Parameters:

TypeNameDescription
ShapeshapeThe shape.
QuatquatThe untransformed quaternion.

Returns:

TypeDescription
QuatThe transformed quaternion.