Body

Associated namespace: sm.body

A userdata object representing a body in the game.

Values:

Functions:

Operations:

OperationDescription
Body == BodyChecks if two instances of Body refer to the same Body.

angularVelocity Vec3

Get:

Returns the angular velocity of a body.


buildable boolean

Get:

Check if a body is buildable

Set:

Server only

Controls whether a body is buildable


centerOfMassPosition Vec3

Get:

Returns the center of mass world position of a body.


connectable boolean

Get:

Check if a body is connectable

Set:

Server only

Controls whether a body is connectable


convertableToDynamic boolean

Get:

Check if a body is convertible to dynamic form

Set:

Server only

Controls whether a body is convertible to dynamic form


destructable boolean

Get:

Check if a body is destructable.

Set:

Server only

Controls whether a body is destructable


erasable boolean

Get:

Check if a body is erasable.

Set:

Server only

Controls whether a body is erasable


id integer

Get:

Returns the id of a body.


liftable boolean

Get:

Check if a body is liftable

Set:

Server only

Controls whether a body is liftable


mass number

Get:

Returns the mass of a body.


paintable boolean

Get:

Check if a body is paintable

Set:

Server only

Controls whether a body is non paintable


usable boolean

Get:

Check if a body is interactable

Set:

Server only

Controls whether a body is interactable


velocity Vec3

Get:

Returns the linear velocity of a body.


worldPosition Vec3

Get:

Returns the world position of a body.


worldRotation Quat

Get:

Returns the world rotation of a body.


createBlock(body, uuid, size, position, forceAccept=nil)

Server only

Create a block on body

Parameters:

TypeNameDescription
BodybodyThe parent body.
UuiduuidThe uuid of the shape.
Vec3sizeThe shape's size.
Vec3positionThe shape's local position.
booleanforceAccept=nilSet true to force the body to accept the shape. (Defaults to true)

createPart(body, uuid, position, z-axis, x-axis, forceAccept=nil)

Server only

Create a part on body

Parameters:

TypeNameDescription
BodybodyThe parent body.
UuiduuidThe uuid of the shape.
Vec3positionThe shape's local position.
Vec3z-axisThe shape's local z direction.
Vec3x-axisThe shape's local x direction.
booleanforceAccept=nilSet true to force the body to accept the shape. (Defaults to true)

getAllSeatedCharacter(body)

Server only

Returns a table with all characters seated in this body

Parameters:

TypeNameDescription
BodybodyThe body.

Returns:

TypeDescription
tableThe table of all seated characters. {Character, ...}

getAngularVelocity(body)

Returns the angular velocity of a body.

Parameters:

TypeNameDescription
BodybodyThe body.

Returns:

TypeDescription
Vec3The body's angular velocity.

getCenterOfMassPosition(body)

Returns the center of mass world position of a body.

Parameters:

TypeNameDescription
BodybodyThe body.

Returns:

TypeDescription
Vec3The body's center of mass world position.

getCreationBodies(body)

Returns a table of all bodies in a creation.

A creation includes all bodies connected by joints, etc.

Parameters:

TypeNameDescription
BodybodyThe body.

Returns:

TypeDescription
tableThe table all bodies in a creation. {Body, ...}

getCreationId(body)

Server only

Returns the id of the creation

Parameters:

TypeNameDescription
BodybodyThe body.

Returns:

TypeDescription
integerThe creation's id

getCreationJoints(body)

Returns a table of all joints that are part of a creation.

A creation includes all bodies connected by joints, etc.

Parameters:

TypeNameDescription
BodybodyThe body.

Returns:

TypeDescription
tableThe table of joints in a creation. {Joint, ...}

getCreationShapes(body)

Returns a table of all shapes that are part of a creation.

A creation includes all bodies connected by joints, etc.

Parameters:

TypeNameDescription
BodybodyThe body.

Returns:

TypeDescription
tableThe table of shapes in a creation. {Shape, ...}

getId(body)

Returns the id of a body.

Parameters:

TypeNameDescription
BodybodyThe body.

Returns:

TypeDescription
integerThe body's id.

getInteractables(body)

Returns a table of all interactables that are part of a body.

This will not return interactables in neighbouring bodies connected by joints, etc.

Parameters:

TypeNameDescription
BodybodyThe body.

Returns:

TypeDescription
tableThe table of interactables in a body. {Interactable, ...}

getJoints(body)

Returns a table of all joints that are part of a body.

This will not return joints in neighbouring bodies.

Parameters:

TypeNameDescription
BodybodyThe body.

Returns:

TypeDescription
tableThe table of joints in a body. {Joint, ...}

getLocalAabb(body)

Get the local aabb of the body.

Parameters:

TypeNameDescription
BodybodyThe body.

Returns:

TypeDescription
Vec3,Vec3Returns the aabb min and max.

getMass(body)

Returns the mass of a body.

Parameters:

TypeNameDescription
BodybodyThe body.

Returns:

TypeDescription
numberThe body's mass.

getShapes(body)

Returns a table of all shapes that are part of a body.

This will not return shapes in neighbouring bodies connected by joints, etc.

Parameters:

TypeNameDescription
BodybodyThe body.

Returns:

TypeDescription
tableThe table of shapes in a body. {Shape, ...}

getVelocity(body)

Returns the linear velocity of a body.

Parameters:

TypeNameDescription
BodybodyThe body.

Returns:

TypeDescription
Vec3The body's linear velocity.

getWorld(body)

Returns the world a body exists in.

Parameters:

TypeNameDescription
BodybodyThe body.

Returns:

TypeDescription
WorldThe world the body exists in.

getWorldAabb(body)

Get the world aabb of the body.

Parameters:

TypeNameDescription
BodybodyThe body.

Returns:

TypeDescription
Vec3,Vec3Returns the aabb min and max.

getWorldPosition(body)

Returns the world position of a body.

Parameters:

TypeNameDescription
BodybodyThe body.

Returns:

TypeDescription
Vec3The body's world position.

hasChanged(body, tick)

Returns true if the given tick is lower than the tick the body was last changed.

Parameters:

TypeNameDescription
BodybodyThe body.
integertickThe tick.

Returns:

TypeDescription
booleanReturns true if the body has been changed.

isBuildable(body)

Check if a body is buildable

Parameters:

TypeNameDescription
BodybodyThe body.

Returns:

TypeDescription
booleanReturn true if the body is buildable.

isConnectable(body)

Check if a body is connectable

Parameters:

TypeNameDescription
BodybodyThe body.

Returns:

TypeDescription
booleanReturn true if the body is connectable.

isConvertibleToDynamic(body)

Check if a body is convertible to dynamic form

Parameters:

TypeNameDescription
BodybodyThe body.

Returns:

TypeDescription
booleanReturn true if the body can be converted to dynamic.

isDestructable(body)

Check if a body is destructable.

Parameters:

TypeNameDescription
BodybodyThe body.

Returns:

TypeDescription
booleanReturn true if the body is destructable.

isDynamic(body)

Check if a body is dynamic

Parameters:

TypeNameDescription
BodybodyThe body.

Returns:

TypeDescription
booleanReturn true if the body is dynamic.

isErasable(body)

Check if a body is erasable.

Parameters:

TypeNameDescription
BodybodyThe body.

Returns:

TypeDescription
booleanReturn true if the body is erasable.

isLiftable(body)

Check if a body is liftable

Parameters:

TypeNameDescription
BodybodyThe body.

Returns:

TypeDescription
booleanReturn true if the body is liftable.

isOnLift(body)

Check if a body is on a lift

Parameters:

TypeNameDescription
BodybodyThe body.

Returns:

TypeDescription
booleanReturn true if the body is on a lift

isPaintable(body)

Check if a body is paintable

Parameters:

TypeNameDescription
BodybodyThe body.

Returns:

TypeDescription
booleanReturn true if the body is paintable.

isStatic(body)

Check if a body is static

Parameters:

TypeNameDescription
BodybodyThe body.

Returns:

TypeDescription
booleanReturn true if the body is static.

isUsable(body)

Check if a body is interactable

Parameters:

TypeNameDescription
BodybodyThe body.

Returns:

TypeDescription
booleanReturn true if the body is interactable.

setBuildable(body, value)

Server only

Controls whether a body is buildable

Parameters:

TypeNameDescription
BodybodyThe body.
booleanvalueWhether the body is buildable.

setConnectable(body, value)

Server only

Controls whether a body is connectable

Parameters:

TypeNameDescription
BodybodyThe body.
booleanvalueWhether the body is connectable.

setConvertibleToDynamic(body, value)

Server only

Controls whether a body is convertible to dynamic form

Parameters:

TypeNameDescription
BodybodyThe body.
booleanvalueWhether the body is convertible to dynamic form.

setDestructable(body, value)

Server only

Controls whether a body is destructable

Parameters:

TypeNameDescription
BodybodyThe body.
booleanvalueWhether the body is destructable.

setErasable(body, value)

Server only

Controls whether a body is erasable

Parameters:

TypeNameDescription
BodybodyThe body.
booleanvalueWhether the body is erasable.

setLiftable(body, value)

Server only

Controls whether a body is liftable

Parameters:

TypeNameDescription
BodybodyThe body.
booleanvalueWhether the body is liftable.

setPaintable(body, value)

Server only

Controls whether a body is non paintable

Parameters:

TypeNameDescription
BodybodyThe body.
booleanvalueWhether the body is paintable.

setUsable(body, value)

Server only

Controls whether a body is interactable

Parameters:

TypeNameDescription
BodybodyThe body.
booleanvalueWhether the body is interactable.

transformPoint(body, point)

Transforms a point from local space to world space.

Parameters:

TypeNameDescription
BodybodyThe body.
Vec3pointThe point in local space.

Returns:

TypeDescription
Vec3The point in world space.