Body
Associated namespace: sm.body
A userdata object representing a body in the game.
Values:
- angularVelocity
- buildable
- centerOfMassPosition
- connectable
- convertableToDynamic
- destructable
- erasable
- id
- liftable
- mass
- paintable
- usable
- velocity
- worldPosition
- worldRotation
Functions:
- createBlock
- createPart
- createWedge
- getAllSeatedCharacter
- getAngularVelocity
- getCenterOfMassPosition
- getCreationBodies
- getCreationId
- getCreationJoints
- getCreationShapes
- getId
- getInteractables
- getJoints
- getLocalAabb
- getMass
- getShapes
- getVelocity
- getWorld
- getWorldAabb
- getWorldPosition
- hasChanged
- isBuildable
- isConnectable
- isConvertibleToDynamic
- isDestructable
- isDynamic
- isErasable
- isLiftable
- isOnLift
- isPaintable
- isStatic
- isUsable
- setBuildable
- setConnectable
- setConvertibleToDynamic
- setDestructable
- setErasable
- setLiftable
- setPaintable
- setUsable
- transformPoint
Operations:
Operation | Description |
---|---|
Body == Body | Checks 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:
Type | Name | Description |
---|---|---|
Body | body | The parent body. |
Uuid | uuid | The uuid of the shape. |
Vec3 | size | The shape's size. |
Vec3 | position | The shape's local position. |
boolean | forceAccept=nil | Set 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:
Type | Name | Description |
---|---|---|
Body | body | The parent body. |
Uuid | uuid | The uuid of the shape. |
Vec3 | position | The shape's local position. |
Vec3 | z-axis | The shape's local z direction. |
Vec3 | x-axis | The shape's local x direction. |
boolean | forceAccept=nil | Set true to force the body to accept the shape. (Defaults to true) |
createWedge(body, uuid, size, position, z-axis, x-axis, forceAccept=nil)
Server only
Creates a wedge attached to a body. The wedge is oriented with one
cathetus along the Y-axis and the other along the Z-axis, forming a right angle. The wedge's
rotation is controlled by z-axis and x-axis parameters, similar to standard part rotation.
Parameters:
Type | Name | Description |
---|---|---|
Body | body | The parent body. |
Uuid | uuid | The uuid of the shape. |
Vec3 | size | The shape's size. |
Vec3 | position | The shape's local position. |
Vec3 | z-axis | The shape's local z direction. |
Vec3 | x-axis | The shape's local x direction. |
boolean | forceAccept=nil | Set 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:
Type | Name | Description |
---|---|---|
Body | body | The body. |
Returns:
Type | Description |
---|---|
table | The table of all seated characters. {Character, ...} |
getAngularVelocity(body)
Returns the angular velocity of a body.
Parameters:
Type | Name | Description |
---|---|---|
Body | body | The body. |
Returns:
Type | Description |
---|---|
Vec3 | The body's angular velocity. |
getCenterOfMassPosition(body)
Returns the center of mass world position of a body.
Parameters:
Type | Name | Description |
---|---|---|
Body | body | The body. |
Returns:
Type | Description |
---|---|
Vec3 | The 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:
Type | Name | Description |
---|---|---|
Body | body | The body. |
Returns:
Type | Description |
---|---|
table | The table all bodies in a creation. {Body, ...} |
getCreationId(body)
Server only
Returns the id of the creation
Parameters:
Type | Name | Description |
---|---|---|
Body | body | The body. |
Returns:
Type | Description |
---|---|
integer | The 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:
Type | Name | Description |
---|---|---|
Body | body | The body. |
Returns:
Type | Description |
---|---|
table | The 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:
Type | Name | Description |
---|---|---|
Body | body | The body. |
Returns:
Type | Description |
---|---|
table | The table of shapes in a creation. {Shape, ...} |
getId(body)
Returns the id of a body.
Parameters:
Type | Name | Description |
---|---|---|
Body | body | The body. |
Returns:
Type | Description |
---|---|
integer | The 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:
Type | Name | Description |
---|---|---|
Body | body | The body. |
Returns:
Type | Description |
---|---|
table | The 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:
Type | Name | Description |
---|---|---|
Body | body | The body. |
Returns:
Type | Description |
---|---|
table | The table of joints in a body. {Joint, ...} |
getLocalAabb(body)
Get the local aabb of the body.
Parameters:
Type | Name | Description |
---|---|---|
Body | body | The body. |
Returns:
Type | Description |
---|---|
Vec3,Vec3 | Returns the aabb min and max. |
getMass(body)
Returns the mass of a body.
Parameters:
Type | Name | Description |
---|---|---|
Body | body | The body. |
Returns:
Type | Description |
---|---|
number | The 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:
Type | Name | Description |
---|---|---|
Body | body | The body. |
Returns:
Type | Description |
---|---|
table | The table of shapes in a body. {Shape, ...} |
getVelocity(body)
Returns the linear velocity of a body.
Parameters:
Type | Name | Description |
---|---|---|
Body | body | The body. |
Returns:
Type | Description |
---|---|
Vec3 | The body's linear velocity. |
getWorld(body)
Returns the world a body exists in.
Parameters:
Type | Name | Description |
---|---|---|
Body | body | The body. |
Returns:
Type | Description |
---|---|
World | The world the body exists in. |
getWorldAabb(body)
Get the world aabb of the body.
Parameters:
Type | Name | Description |
---|---|---|
Body | body | The body. |
Returns:
Type | Description |
---|---|
Vec3,Vec3 | Returns the aabb min and max. |
getWorldPosition(body)
Returns the world position of a body.
Parameters:
Type | Name | Description |
---|---|---|
Body | body | The body. |
Returns:
Type | Description |
---|---|
Vec3 | The body's world position. |
hasChanged(body, tick)
Returns true if the given tick is lower than the tick the body was last changed.
Parameters:
Type | Name | Description |
---|---|---|
Body | body | The body. |
integer | tick | The tick. |
Returns:
Type | Description |
---|---|
boolean | Returns true if the body has been changed. |
isBuildable(body)
Check if a body is buildable
Parameters:
Type | Name | Description |
---|---|---|
Body | body | The body. |
Returns:
Type | Description |
---|---|
boolean | Return true if the body is buildable. |
isConnectable(body)
Check if a body is connectable
Parameters:
Type | Name | Description |
---|---|---|
Body | body | The body. |
Returns:
Type | Description |
---|---|
boolean | Return true if the body is connectable. |
isConvertibleToDynamic(body)
Check if a body is convertible to dynamic form
Parameters:
Type | Name | Description |
---|---|---|
Body | body | The body. |
Returns:
Type | Description |
---|---|
boolean | Return true if the body can be converted to dynamic. |
isDestructable(body)
Check if a body is destructable.
Parameters:
Type | Name | Description |
---|---|---|
Body | body | The body. |
Returns:
Type | Description |
---|---|
boolean | Return true if the body is destructable. |
isDynamic(body)
Check if a body is dynamic
Parameters:
Type | Name | Description |
---|---|---|
Body | body | The body. |
Returns:
Type | Description |
---|---|
boolean | Return true if the body is dynamic. |
isErasable(body)
Check if a body is erasable.
Parameters:
Type | Name | Description |
---|---|---|
Body | body | The body. |
Returns:
Type | Description |
---|---|
boolean | Return true if the body is erasable. |
isLiftable(body)
Check if a body is liftable
Parameters:
Type | Name | Description |
---|---|---|
Body | body | The body. |
Returns:
Type | Description |
---|---|
boolean | Return true if the body is liftable. |
isOnLift(body)
Check if a body is on a lift
Parameters:
Type | Name | Description |
---|---|---|
Body | body | The body. |
Returns:
Type | Description |
---|---|
boolean | Return true if the body is on a lift |
isPaintable(body)
Check if a body is paintable
Parameters:
Type | Name | Description |
---|---|---|
Body | body | The body. |
Returns:
Type | Description |
---|---|
boolean | Return true if the body is paintable. |
isStatic(body)
Check if a body is static
Parameters:
Type | Name | Description |
---|---|---|
Body | body | The body. |
Returns:
Type | Description |
---|---|
boolean | Return true if the body is static. |
isUsable(body)
Check if a body is interactable
Parameters:
Type | Name | Description |
---|---|---|
Body | body | The body. |
Returns:
Type | Description |
---|---|
boolean | Return true if the body is interactable. |
setBuildable(body, value)
Server only
Controls whether a body is buildable
Parameters:
Type | Name | Description |
---|---|---|
Body | body | The body. |
boolean | value | Whether the body is buildable. |
setConnectable(body, value)
Server only
Controls whether a body is connectable
Parameters:
Type | Name | Description |
---|---|---|
Body | body | The body. |
boolean | value | Whether the body is connectable. |
setConvertibleToDynamic(body, value)
Server only
Controls whether a body is convertible to dynamic form
Parameters:
Type | Name | Description |
---|---|---|
Body | body | The body. |
boolean | value | Whether the body is convertible to dynamic form. |
setDestructable(body, value)
Server only
Controls whether a body is destructable
Parameters:
Type | Name | Description |
---|---|---|
Body | body | The body. |
boolean | value | Whether the body is destructable. |
setErasable(body, value)
Server only
Controls whether a body is erasable
Parameters:
Type | Name | Description |
---|---|---|
Body | body | The body. |
boolean | value | Whether the body is erasable. |
setLiftable(body, value)
Server only
Controls whether a body is liftable
Parameters:
Type | Name | Description |
---|---|---|
Body | body | The body. |
boolean | value | Whether the body is liftable. |
setPaintable(body, value)
Server only
Controls whether a body is non paintable
Parameters:
Type | Name | Description |
---|---|---|
Body | body | The body. |
boolean | value | Whether the body is paintable. |
setUsable(body, value)
Server only
Controls whether a body is interactable
Parameters:
Type | Name | Description |
---|---|---|
Body | body | The body. |
boolean | value | Whether the body is interactable. |
transformPoint(body, point)
Transforms a point from local space to world space.
Parameters:
Type | Name | Description |
---|---|---|
Body | body | The body. |
Vec3 | point | The point in local space. |
Returns:
Type | Description |
---|---|
Vec3 | The point in world space. |