atl/sm.hpp
The core Scrap Mechanic API: game object types (Shape, Body, Interactable, Character, Player, World, ...) and the sm.* namespaces that operate on them.
Functions
Section titled "Functions"template <class F> String bindCallback(F fn);For engine APIs that take the name of a callback method: returns the name of a
method on the running script's class that calls fn(args) (args[1] is the first
argument). Released with the script, like GUI callbacks.
Parameters
fn(F)
Returns String
inline constexpr Connection operator|(Connection a, Connection b);Combines connection flags.
Parameters
a(Connection)b(Connection)
Returns Connection
inline constexpr size_t kNetworkPacketLimit = ATL_NETWORK_PACKET_LIMIT;The most bytes one network send may carry (method name, data and the game's framing): a string payload costs its length + the method name's length + 14. Typed messages split themselves up; raw sends over it raise a Lua error, so check those against it.
inline bool isServer();True when running on the server side.
Returns bool
Lua: sm.isServerMode
inline bool isHost();True when this game instance hosts the session.
Returns bool
Lua: sm.isHost
Connection
Section titled "Connection"Connection types between interactables, combinable with |.
enum class Connection : int { None = 0, Logic = 1, Power = 2, Bearing = 4, Seated = 8, Piston = 16, Gasoline = 256, Electricity = 512, Water = 1024, Ammo = 2048,};An axis-aligned bounding box.
struct AabbVec3 min, max;Sticky
Section titled "Sticky"The positive-xyz and negative-xyz sticky directions of a shape or joint.
struct StickyVec3 positive, negative;TerrainColor
Section titled "TerrainColor"A terrain color (TerrainScript, sm::terrainTile).
struct TerrainColordouble r = 0, g = 0, b = 0;MaterialWeights
Section titled "MaterialWeights"The 8 ground material weights at a terrain point.
struct MaterialWeightsdouble weights[8] = {};MineSpawn
Section titled "MineSpawn"One mining loot spawn (WorldClass::server_onMining).
struct MineSpawnVec3 position;int spawnId = 0;Destruction
Section titled "Destruction"How a shape is destroyed (type is an sm.shape.destructionType value).
struct Destructionint attackLevel = 0;Optional<int> type;Optional<Vec3> position;Optional<Vec3> normal;AnimationInfo
Section titled "AnimationInfo"Information about an animation: name, length in seconds, and whether it loops.
struct AnimationInfoString name;double duration = 0;bool looping = false;static AnimationInfo from(const Value &t);Reads the game's animation info table.
Parameters
t(const Value &)
Returns AnimationInfo
ActiveAnimation
Section titled "ActiveAnimation"An animation that is playing, and its blend weight.
struct ActiveAnimationString name;double weight = 0;A block or part in the world (Lua Shape).
class Shape : public atl::Objectint id() const;The shape's unique id.
Returns int
Lua: Shape:getId
Uuid uuid() const;The shape's item uuid.
Returns Uuid
Lua: Shape:getShapeUuid
Body body() const;The body the shape belongs to.
Returns Body
Lua: Shape:getBody
Interactable interactable() const;The shape's interactable, or empty for a plain block.
Returns Interactable
Lua: Shape:getInteractable
Vec3 worldPosition() const;Position and rotation in the world, and relative to the body.
Returns Vec3
Lua: Shape:getWorldPosition
Quat worldRotation() const;Position and rotation in the world, and relative to the body.
Returns Quat
Lua: Shape:getWorldRotation
Vec3 localPosition() const;Position and rotation in the world, and relative to the body.
Returns Vec3
Lua: Shape:getLocalPosition
Quat localRotation() const;Position and rotation in the world, and relative to the body.
Returns Quat
Lua: Shape:getLocalRotation
Vec3 velocity() const;Velocity in meters per second.
Returns Vec3
Lua: Shape:getVelocity
Vec3 at() const;The shape's forward (at), up and right directions in the world.
Returns Vec3
Lua: Shape:getAt
Vec3 up() const;The shape's forward (at), up and right directions in the world.
Returns Vec3
Lua: Shape:getUp
Vec3 right() const;The shape's forward (at), up and right directions in the world.
Returns Vec3
Lua: Shape:getRight
Vec3 xAxis() const;The shape's local x, y and z axes in world space.
Returns Vec3
Lua: Shape:getXAxis
Vec3 yAxis() const;The shape's local x, y and z axes in world space.
Returns Vec3
Lua: Shape:getYAxis
Vec3 zAxis() const;The shape's local x, y and z axes in world space.
Returns Vec3
Lua: Shape:getZAxis
Vec3 boundingBox() const;Size in blocks.
Returns Vec3
Lua: Shape:getBoundingBox
Aabb localAabb() const;The bounding box in body-local coordinates.
Returns Aabb
double mass() const;Mass in kilograms.
Returns double
Lua: Shape:getMass
String material() const;The physics material name.
Returns String
Lua: Shape:getMaterial
Color color() const;The paint color.
Returns Color
Lua: Shape:getColor
void setColor(Color c) const;[server] Paints the shape.
Parameters
c(Color): The color.
Lua: Shape:setColor
bool burning() const;True while the shape burns.
Returns bool
Lua: Shape:getBurning
void setBurning(bool b) const;[server] Sets the shape on fire or puts it out.
Parameters
b(bool): The state.
Lua: Shape:setBurning
Vec3 transformPoint(Vec3 worldPoint) const;World point / direction to shape-local.
Parameters
worldPoint(Vec3): The world point.
Returns Vec3
Lua: Shape:transformPoint
Vec3 transformDirection(Vec3 worldDir) const;World point / direction to shape-local.
Parameters
worldDir(Vec3): The untransformed direction.
Returns Vec3
Lua: Shape:transformDirection
Vec3 transformLocalPoint(Vec3 localPoint) const;Shape-local point / direction to world.
Parameters
localPoint(Vec3): The local point.
Returns Vec3
Lua: Shape:transformLocalPoint
Vec3 transformLocalDirection(Vec3 localDir) const;Shape-local point / direction to world.
Parameters
localDir(Vec3): The local direction.
Returns Vec3
Lua: Shape:transformLocalDirection
Vector<Joint> joints(bool onlyChildJoints = false) const;Joints attached to the shape, optionally only those it's the parent of.
Parameters
onlyChildJoints(bool)
Returns Vector<Joint>
Vector<Shape> neighbours() const;[server] Shapes touching this one.
Returns Vector<Shape>
Vec3 interpolatedWorldPosition() const;Positions and directions smoothed between physics ticks, for rendering.
Returns Vec3
Lua: Shape:getInterpolatedWorldPosition
Vec3 interpolatedAt() const;Positions and directions smoothed between physics ticks, for rendering.
Returns Vec3
Lua: Shape:getInterpolatedAt
Vec3 interpolatedUp() const;Positions and directions smoothed between physics ticks, for rendering.
Returns Vec3
Lua: Shape:getInterpolatedUp
Vec3 interpolatedRight() const;Positions and directions smoothed between physics ticks, for rendering.
Returns Vec3
Lua: Shape:getInterpolatedRight
Quat transformRotation(Quat worldRotation) const;A world rotation in shape-local terms.
Parameters
worldRotation(Quat): The untransformed quaternion.
Returns Quat
Lua: Shape:transformRotation
Vec3 closestBlockLocalPosition(Vec3 worldPosition) const;The local position of the shape's block nearest to a world position.
Parameters
worldPosition(Vec3): The world position.
Returns Vec3
Lua: Shape:getClosestBlockLocalPosition
double buoyancy() const;Buoyancy of the shape's material.
Returns double
Lua: Shape:getBuoyancy
int materialId() const;The physics material id.
Returns int
Lua: Shape:getMaterialId
void setPhysicsMaterial(int material) const;[client] Overrides the physics material.
Parameters
material(int): The new physics material for the shape.
Lua: Shape:setPhysicsMaterial
void setCollisionSoundEnabled(bool on) const;Turns collision sounds on or off.
Parameters
on(bool): Whether the sound should be enabled or not.
Lua: Shape:setCollisionSoundEnabled
bool isHarvest() const;True for a harvested item.
Returns bool
Lua: Shape:getIsHarvest
bool isStackable() const;True if the item stacks.
Returns bool
Lua: Shape:getIsStackable
Sticky sticky() const;The sticky directions.
Returns Sticky
bool compromised() const;True when the shape is structurally weakened.
Returns bool
Lua: Shape:getCompromised
void setCompromised(bool on) const;[server] Weakens or restores the shape.
Parameters
on(bool): The state.
Lua: Shape:setCompromised
void removeColor() const;[server] Back to the shape's default color.
Lua: Shape:removeColor
void applyShakeImpulse(double shake) const;[client] Shakes the shape visually.
Parameters
shake(double): The shake impulse value.
Lua: Shape:applyShakeImpulse
Vector<Shape> multiShapeShapes() const;The shapes and joints of the multi-shape item this shape belongs to.
Returns Vector<Shape>
Vector<Joint> multiShapeJoints() const;The shapes and joints of the multi-shape item this shape belongs to.
Returns Vector<Joint>
bool isPipe() const;True for pipe parts.
Returns bool
Lua: Shape:isPipe
Vector<Vec3> pipeOffsets(Optional<int> direction = atl::none) const;Pipe connection offsets, optionally for one direction only.
Parameters
direction(Optional<int>)
Returns Vector<Vec3>
Vector<Shape> pipedNeighbours() const;[server] Pipes connected to this one.
Returns Vector<Shape>
int outputContainerIndex() const;The output container index from the shapeset, for pipe graphs.
Returns int
Lua: Shape:getShapeOutputContainerIndex
void applyImpulse(Vec3 impulse, bool worldSpace = false, Vec3 offset = {}) const;[server] Applies an impulse (sm.physics.applyImpulse), in local space unless worldSpace.
Parameters
impulse(Vec3)worldSpace(bool)offset(Vec3)
Lua: sm.physics.applyImpulse
void destroy(int attackLevel = 0) const;[server] Destroys the shape with an attack level.
Parameters
attackLevel(int)
Lua: Shape:destroyShape
void destroy(const Destruction &d) const;[server] Destroys the shape with full destruction details.
Parameters
d(const Destruction &)
Lua: Shape:destroyShape
void destroyBlock(Vec3 localPosition, Vec3 size = {1, 1, 1}, const Destruction &d = {}) const;[server] Removes the blocks of a block shape in the box at localPosition (a corner) of size.
Parameters
localPosition(Vec3)size(Vec3)d(const Destruction &)
Lua: Shape:destroyBlock
void replace(const Uuid &uuid) const;[server] Replaces the shape with another item, keeping its position.
Parameters
uuid(const Uuid &): The uuid of the new shape.
Lua: Shape:replaceShape
Joint createJoint(const Uuid &uuid, Vec3 localPosition, Vec3 direction) const;[server] Creates a joint on this shape at grid localPosition, facing direction.
Parameters
uuid(const Uuid &)localPosition(Vec3)direction(Vec3)
Returns Joint
Lua: Shape:createJoint
A rigid body: shapes connected without joints (Lua Body).
class Body : public atl::Objectint id() const;The body's id.
Returns int
Lua: Body:getId
int creationId() const;[server] The id of the creation (bodies connected by joints) it belongs to.
Returns int
Lua: Body:getCreationId
World world() const;The world the body is in.
Returns World
Lua: Body:getWorld
Vec3 worldPosition() const;Position of the body's origin.
Returns Vec3
Lua: Body:getWorldPosition
Vec3 centerOfMass() const;Center of mass in world space.
Returns Vec3
Lua: Body:getCenterOfMassPosition
Vec3 velocity() const;Linear / angular velocity.
Returns Vec3
Lua: Body:getVelocity
Vec3 angularVelocity() const;Linear / angular velocity.
Returns Vec3
Lua: Body:getAngularVelocity
double mass() const;Mass in kilograms.
Returns double
Lua: Body:getMass
Aabb localAabb() const;Bounding box in body-local / world coordinates.
Returns Aabb
Aabb worldAabb() const;Bounding box in body-local / world coordinates.
Returns Aabb
Vector<Shape> shapes() const;The body's shapes, interactables and joints.
Returns Vector<Shape>
Vector<Interactable> interactables() const;The body's shapes, interactables and joints.
Returns Vector<Interactable>
Vector<Joint> joints() const;The body's shapes, interactables and joints.
Returns Vector<Joint>
Vector<Body> creationBodies() const;The bodies, shapes and joints of the whole creation.
Returns Vector<Body>
Vector<Shape> creationShapes() const;The bodies, shapes and joints of the whole creation.
Returns Vector<Shape>
Vector<Joint> creationJoints() const;The bodies, shapes and joints of the whole creation.
Returns Vector<Joint>
Vector<Character> seatedCharacters() const;[server] Characters seated in the body.
Returns Vector<Character>
int shapeCount() const;Number of shapes.
Returns int
Lua: Body:getShapeCount
Shape shape(int index) const;Shape by index.
Parameters
index(int): The index of the shape.
Returns Shape
Lua: Body:getShape
Vector<Shape> shapesByUuid(const Uuid &uuid) const;Shapes of one item type.
Parameters
uuid(const Uuid &)
Returns Vector<Shape>
bool hasChanged(int tick) const;True if the body changed after tick (compare with game::currentTick()).
Parameters
tick(int)
Returns bool
Lua: Body:hasChanged
Lift lift() const;The lift the body is on (empty if none).
Returns Lift
Lua: sm.body.getLift
bool isGhost() const;True for a ghost (non-colliding) body.
Returns bool
Lua: Body:isGhost
bool isOnVirtualLift() const;True when held by a virtual lift.
Returns bool
Lua: Body:isOnVirtualLift
bool isConnectable() const;Permission flags: whether the body can be connected to, lifted, or made dynamic.
Returns bool
Lua: Body:isConnectable
bool isLiftable() const;Permission flags: whether the body can be connected to, lifted, or made dynamic.
Returns bool
Lua: Body:isLiftable
bool isConvertibleToDynamic() const;Permission flags: whether the body can be connected to, lifted, or made dynamic.
Returns bool
Lua: Body:isConvertibleToDynamic
void setConnectable(bool v) const;[server] Sets those permission flags.
Parameters
v(bool)
Lua: Body:setConnectable
void setLiftable(bool v) const;[server] Sets those permission flags.
Parameters
v(bool): Whether the body is liftable.
Lua: Body:setLiftable
void setConvertibleToDynamic(bool v) const;[server] Sets those permission flags.
Parameters
v(bool): Whether the body is convertible to dynamic form.
Lua: Body:setConvertibleToDynamic
bool isStatic() const;True if the body is static / dynamic.
Returns bool
Lua: Body:isStatic
bool isDynamic() const;True if the body is static / dynamic.
Returns bool
Lua: Body:isDynamic
bool isOnLift() const;True when on a lift.
Returns bool
Lua: Body:isOnLift
bool isBuildable() const;Permission flags: building, destruction, erasing, painting and use.
Returns bool
Lua: Body:isBuildable
bool isDestructable() const;Permission flags: building, destruction, erasing, painting and use.
Returns bool
Lua: Body:isDestructable
bool isErasable() const;Permission flags: building, destruction, erasing, painting and use.
Returns bool
Lua: Body:isErasable
bool isPaintable() const;Permission flags: building, destruction, erasing, painting and use.
Returns bool
Lua: Body:isPaintable
bool isUsable() const;Permission flags: building, destruction, erasing, painting and use.
Returns bool
Lua: Body:isUsable
void setBuildable(bool v) const;[server] Sets those permission flags.
Parameters
v(bool)
Lua: Body:setBuildable
void setDestructable(bool v) const;[server] Sets those permission flags.
Parameters
v(bool): Whether the body is destructable.
Lua: Body:setDestructable
void setErasable(bool v) const;[server] Sets those permission flags.
Parameters
v(bool): Whether the body is erasable.
Lua: Body:setErasable
void setPaintable(bool v) const;[server] Sets those permission flags.
Parameters
v(bool): Whether the body is paintable.
Lua: Body:setPaintable
void setUsable(bool v) const;[server] Sets those permission flags.
Parameters
v(bool): Whether the body is interactable.
Lua: Body:setUsable
Vec3 transformPoint(Vec3 worldPoint) const;World point to body-local.
Parameters
worldPoint(Vec3): The point in world space.
Returns Vec3
Lua: Body:transformPoint
Vec3 transformLocalPoint(Vec3 localPoint) const;Body-local point to world.
Parameters
localPoint(Vec3): The point in local space.
Returns Vec3
Lua: Body:transformLocalPoint
Vec3 transformWorldPoint(Vec3 worldPoint) const;World space to the body's local space.
Parameters
worldPoint(Vec3): The point in world space.
Returns Vec3
Lua: Body:transformWorldPoint
void applyImpulse(Vec3 impulse, bool worldSpace = false, Vec3 offset = {}) const;[server] Applies an impulse (sm.physics.applyImpulse), in local space unless worldSpace.
Parameters
impulse(Vec3)worldSpace(bool)offset(Vec3)
Lua: sm.physics.applyImpulse
void applyTorque(Vec3 torque, bool worldSpace = false) const;[server] Applies a torque (sm.physics.applyTorque), in local space unless worldSpace.
Parameters
torque(Vec3)worldSpace(bool)
Lua: sm.physics.applyTorque
Shape createBlock(const Uuid &uuid, Vec3 size, Vec3 localPosition, bool forceAccept = false) const;[server] Adds a block. forceAccept skips the overlap check.
Parameters
uuid(const Uuid &): The uuid of the shape.size(Vec3): The shape's size.localPosition(Vec3): The shape's local position.forceAccept(bool): Set true to force the body to accept the shape. (Defaults to true)
Returns Shape
Lua: Body:createBlock
Shape createPart(const Uuid &uuid, Vec3 localPosition, Vec3 zAxis, Vec3 xAxis, bool forceAccept = false) const;[server] Adds a part oriented by its z and x axes.
Parameters
uuid(const Uuid &): The uuid of the shape.localPosition(Vec3): The shape's local position.zAxis(Vec3): The shape's local z direction.xAxis(Vec3): The shape's local x direction.forceAccept(bool): Set true to force the body to accept the shape. (Defaults to true)
Returns Shape
Lua: Body:createPart
void createWedge(const Uuid &uuid, Vec3 size, Vec3 localPosition, Vec3 zAxis, Vec3 xAxis, bool forceAccept = false) const;[server] Adds a wedge.
Parameters
uuid(const Uuid &): The uuid of the shape.size(Vec3): The shape's size.localPosition(Vec3): The shape's local position.zAxis(Vec3): The shape's local z direction.xAxis(Vec3): The shape's local x direction.forceAccept(bool): Set true to force the body to accept the shape. (Defaults to true)
Lua: Body:createWedge
void destroyCreation() const;[server] Destroys the whole creation.
Lua: Body:destroyCreation
Interactable
Section titled "Interactable"The scripted, connectable side of a part (Lua Interactable).
class Interactable : public atl::Objectint id() const;The interactable's id.
Returns int
Lua: Interactable:getId
Shape shape() const;The shape and body it belongs to.
Returns Shape
Lua: Interactable:getShape
Body body() const;The shape and body it belongs to.
Returns Body
Lua: Interactable:getBody
String type() const;The interactable type, e.g. "engine".
Returns String
Lua: Interactable:getType
bool isActive() const;True when active (on).
Returns bool
Lua: Interactable:isActive
void setActive(bool on) const;[server] Turns the interactable on or off.
Parameters
on(bool): The logic output signal.
Lua: Interactable:setActive
double power() const;The output power value.
Returns double
Lua: Interactable:getPower
void setPower(double p) const;[server] Sets the output power.
Parameters
p(double): The power output signal.
Lua: Interactable:setPower
Vector<Interactable> parents(Optional<Connection> filter = atl::none) const;Interactables connected as inputs / outputs, optionally of one connection type.
Parameters
filter(Optional<Connection>)
Returns Vector<Interactable>
Vector<Interactable> children(Optional<Connection> filter = atl::none) const;Interactables connected as inputs / outputs, optionally of one connection type.
Parameters
filter(Optional<Connection>)
Returns Vector<Interactable>
Interactable singleParent() const;The only parent, or empty.
Returns Interactable
Lua: Interactable:getSingleParent
bool connect(const Interactable &child) const;[server] Connects an output to child.
Parameters
child(const Interactable &)
Returns bool
Lua: Interactable:connect
bool disconnect(const Interactable &child) const;[server] Removes a connection to child.
Parameters
child(const Interactable &)
Returns bool
Lua: Interactable:disconnect
Value publicData() const;[server] Data other scripts can read.
Returns Value
Lua: Interactable:getPublicData
void setPublicData(const Value &t) const;[server] Sets data other scripts can read.
Parameters
t(const Value &): The public data.
Lua: Interactable:setPublicData
bool hasSeat() const;True if the part has a seat.
Returns bool
Lua: Interactable:hasSeat
Character seatCharacter() const;The character in the seat.
Returns Character
Lua: Interactable:getSeatCharacter
void setUvFrameIndex(int index) const;[client] Visual state: UV frame, glow, animations and sub-mesh visibility.
Parameters
index(int): The index.
Lua: Interactable:setUvFrameIndex
void setGlowMultiplier(double v) const;[client] Visual state: UV frame, glow, animations and sub-mesh visibility.
Parameters
v(double): The glow multiplier (0.0 - 1.0).
Lua: Interactable:setGlowMultiplier
void setAnimEnabled(StringView name, bool on) const;[client] Visual state: UV frame, glow, animations and sub-mesh visibility.
Parameters
name(StringView): The name of the animation.on(bool): The boolean enable state.
Lua: Interactable:setAnimEnabled
void setAnimProgress(StringView name, double progress) const;[client] Visual state: UV frame, glow, animations and sub-mesh visibility.
Parameters
name(StringView): The name of the animation.progress(double): The animation's progress between 0 and 1.
Lua: Interactable:setAnimProgress
void setSubMeshVisible(StringView name, bool visible) const;[client] Visual state: UV frame, glow, animations and sub-mesh visibility.
Parameters
name(StringView): Name of the submesh.visible(bool): True if the submesh should be visible.
Lua: Interactable:setSubMeshVisible
Container container(int index = 0) const;A container of the interactable by index.
Parameters
index(int)
Returns Container
Lua: Interactable:getContainer
Container addContainer(int index, int size, Optional<int> stackSize = atl::none) const;[server] Adds a container of size slots.
Parameters
index(int)size(int)stackSize(Optional<int>)
Returns Container
Lua: Interactable:addContainer
void removeContainer(int index) const;[server] Removes a container.
Parameters
index(int): The index of the container.
Lua: Interactable:removeContainer
int maxParentCount() const;How many parents / children may connect.
Returns int
Lua: Interactable:getMaxParentCount
int maxChildCount() const;How many parents / children may connect.
Returns int
Lua: Interactable:getMaxChildCount
Connection inputType() const;The connection types accepted as input / produced as output.
Returns Connection
Lua: Interactable:getConnectionInputType
Connection outputType() const;The connection types accepted as input / produced as output.
Returns Connection
Lua: Interactable:getConnectionOutputType
bool hasOutputType(Connection flags) const;True if the output includes all of flags.
Parameters
flags(Connection): The output type.
Returns bool
Lua: Interactable:hasOutputType
Color connectionColor() const;Connection colors (normal / highlighted).
Returns Color
Lua: Interactable:getColorNormal
Color connectionHighlightColor() const;Connection colors (normal / highlighted).
Returns Color
Lua: Interactable:getColorHighlight
Vector<Joint> joints() const;Connected joints: all of them, bearings only, pistons only.
Returns Vector<Joint>
Vector<Joint> bearings() const;Connected joints: all of them, bearings only, pistons only.
Returns Vector<Joint>
Vector<Joint> pistons() const;Connected joints: all of them, bearings only, pistons only.
Returns Vector<Joint>
void connectToJoint(const Joint &child) const;[server] Connects to a joint (e.g. a bearing) as its controller.
Parameters
child(const Joint &)
Lua: Interactable:connectToJoint
Value jointCustomData(const Joint &joint) const;Data attached to a connected joint.
Parameters
joint(const Joint &): The joint.
Returns Value
Lua: Interactable:getJointCustomData
void setJointCustomData(const Joint &joint, const Value &data) const;[server] Attaches data to a connected joint.
Parameters
joint(const Joint &): The joint.data(const Value &): The data.
Lua: Interactable:setJointCustomData
bool hasChanged(int tick) const;True if the interactable had updates after tick.
Parameters
tick(int): The tick.
Returns bool
Lua: Interactable:hasChanged
Value clientPublicData() const;[client] Data other client scripts can read.
Returns Value
Lua: Interactable:getClientPublicData
void setClientPublicData(const Value &t) const;[client] Sets data other client scripts can read.
Parameters
t(const Value &): The public data.
Lua: Interactable:setClientPublicData
void setParams(const Value &data) const;Params for an interactable created from a script.
Parameters
data(const Value &): The param data.
Lua: Interactable:setParams
Value carryData() const;[server] Data kept when the part is carried.
Returns Value
Lua: Interactable:getCarryData
void setCarryData(const Value &data) const;[server] Sets data kept when the part is carried.
Parameters
data(const Value &): The carry data.
Lua: Interactable:setCarryData
void onDamageDestruction(atl::Function<void()> fn) const;[server] Runs when the interactable is destroyed by damage.
Parameters
fn(atl::Function<void ()>): The name of the lua function to bind.
Lua: Interactable:bindDamageDestruction
void setSeatCharacter(const Character &character) const;Requests to seat character (empty to unseat).
Parameters
character(const Character &): The character.
Lua: Interactable:setSeatCharacter
Vector<Interactable> seatInteractables() const;Interactables the seat controls (the hotbar of a seat).
Returns Vector<Interactable>
bool pressSeatInteractable(int index) const;Presses / releases a seat hotbar slot.
Parameters
index(int): The index of the interactable to press.
Returns bool
Lua: Interactable:pressSeatInteractable
bool releaseSeatInteractable(int index) const;Presses / releases a seat hotbar slot.
Parameters
index(int): The index of the interactable to release.
Returns bool
Lua: Interactable:releaseSeatInteractable
bool hasSteering() const;True for a driver's seat with steering.
Returns bool
Lua: Interactable:hasSteering
double steeringAngle() const;Steering input: A = -1, D = 1.
Returns double
Lua: Interactable:getSteeringAngle
double steeringPower() const;Throttle input: W = 1, S = -1.
Returns double
Lua: Interactable:getSteeringPower
bool steeringSprint() const;True while sprinting in the seat.
Returns bool
Lua: Interactable:getSteeringSprint
void setSteeringFlag(int flags) const;Sets / clears steering flags.
Parameters
flags(int): The steering flags.
Lua: Interactable:setSteeringFlag
void unsetSteeringFlag(int flags) const;Sets / clears steering flags.
Parameters
flags(int): The steering flags.
Lua: Interactable:unsetSteeringFlag
SteeringJoint steeringJoint(const Joint &joint) const;Reads a bearing's steering settings.
Parameters
joint(const Joint &)
Returns SteeringJoint
void setSteeringJoint(const Joint &joint, const SteeringJoint &s) const;[client] Writes a bearing's steering settings.
Parameters
joint(const Joint &)s(const SteeringJoint &)
Lua: Interactable:setSteeringJointSettings
double steeringJointLeftAngleLimit(const Joint &joint) const;Read a single steering setting of a bearing.
Parameters
joint(const Joint &)
Returns double
Lua: Interactable:getSteeringJointLeftAngleLimit
double steeringJointRightAngleLimit(const Joint &joint) const;Read a single steering setting of a bearing.
Parameters
joint(const Joint &)
Returns double
Lua: Interactable:getSteeringJointRightAngleLimit
double steeringJointLeftAngleSpeed(const Joint &joint) const;Read a single steering setting of a bearing.
Parameters
joint(const Joint &)
Returns double
Lua: Interactable:getSteeringJointLeftAngleSpeed
double steeringJointRightAngleSpeed(const Joint &joint) const;Read a single steering setting of a bearing.
Parameters
joint(const Joint &)
Returns double
Lua: Interactable:getSteeringJointRightAngleSpeed
bool steeringJointUnlocked(const Joint &joint) const;Read a single steering setting of a bearing.
Parameters
joint(const Joint &): The joint.
Returns bool
Lua: Interactable:getSteeringJointUnlocked
void setSteeringJointLeftAngleLimit(const Joint &joint, double v) const;[client] Write a single steering setting of a bearing.
Parameters
joint(const Joint &): The joint.v(double): The left angle limit.
Lua: Interactable:setSteeringJointLeftAngleLimit
void setSteeringJointRightAngleLimit(const Joint &joint, double v) const;[client] Write a single steering setting of a bearing.
Parameters
joint(const Joint &): The joint.v(double): The right angle limit.
Lua: Interactable:setSteeringJointRightAngleLimit
void setSteeringJointLeftAngleSpeed(const Joint &joint, double v) const;[client] Write a single steering setting of a bearing.
Parameters
joint(const Joint &): The joint.v(double): The left angle speed.
Lua: Interactable:setSteeringJointLeftAngleSpeed
void setSteeringJointRightAngleSpeed(const Joint &joint, double v) const;[client] Write a single steering setting of a bearing.
Parameters
joint(const Joint &): The joint.v(double): The right angle speed.
Lua: Interactable:setSteeringJointRightAngleSpeed
void setSteeringJointUnlocked(const Joint &joint, bool unlocked) const;[client] Write a single steering setting of a bearing.
Parameters
joint(const Joint &): The joint.unlocked(bool): true if joint is unlocked
Lua: Interactable:setSteeringJointUnlocked
void setGyroDirection(Vec3 direction) const;[client] Gyro / turret seats: aim direction, force and maximum speed.
Parameters
direction(Vec3): The gyro direction.
Lua: Interactable:setGyroDirection
void setGyroForce(double force) const;[client] Gyro / turret seats: aim direction, force and maximum speed.
Parameters
force(double)
Lua: Interactable:setGyroForce
void setGyroMaxSpeed(double speed) const;[client] Gyro / turret seats: aim direction, force and maximum speed.
Parameters
speed(double)
Lua: Interactable:setGyroMaxSpeed
void setLightOverrideColor(Color c) const;[server] Overrides / restores the light color.
Parameters
c(Color): The color to override with.
Lua: Interactable:setLightOverrideColor
void clearLightOverrideColor() const;[server] Overrides / restores the light color.
Lua: Interactable:clearLightOverrideColor
double glowMultiplier() const;The current glow multiplier.
Returns double
Lua: Interactable:getGlowMultiplier
int uvFrameIndex() const;[client] The current UV frame.
Returns int
Lua: Interactable:getUvFrameIndex
double poseWeight(int index) const;[client] Reads / writes an animation pose weight.
Parameters
index(int)
Returns double
Lua: Interactable:getPoseWeight
void setPoseWeight(int index, double weight) const;[client] Reads / writes an animation pose weight.
Parameters
index(int): The index.weight(double): The pose weight.
Lua: Interactable:setPoseWeight
bool hasAnim(StringView name) const;[client] True if the animation exists.
Parameters
name(StringView): The name of the animation.
Returns bool
Lua: Interactable:hasAnim
double animDuration(StringView name) const;[client] An animation's length in seconds.
Parameters
name(StringView)
Returns double
Lua: Interactable:getAnimDuration
bool isAnimLooping(StringView name) const;[client] True if an animation loops.
Parameters
name(StringView): The name of the animation.
Returns bool
Lua: Interactable:isAnimLooping
Vec3 localBonePosition(StringView bone) const;A bone's position, local / in the world.
Parameters
bone(StringView)
Returns Vec3
Lua: Interactable:getLocalBonePosition
Vec3 worldBonePosition(StringView bone) const;A bone's position, local / in the world.
Parameters
bone(StringView): The bone name.
Returns Vec3
Lua: Interactable:getWorldBonePosition
SteeringJoint
Section titled "SteeringJoint"Steering settings of a connected bearing.
struct SteeringJointdouble leftAngleSpeed = 0, rightAngleSpeed = 0, leftAngleLimit = 0, rightAngleLimit = 0;bool unlocked = false;A joint: bearing, piston, spring or similar (Lua Joint).
class Joint : public atl::Objectint id() const;The joint's id.
Returns int
Lua: Joint:getId
String type() const;The joint type, e.g. "bearing" or "piston".
Returns String
Lua: Joint:getType
Shape shapeA() const;The shape the joint is placed on.
Returns Shape
Lua: Joint:getShapeA
Shape shapeB() const;The shape on the joint's far side; empty when nothing is attached.
Returns Shape
Lua: Joint:getShapeB
Uuid uuid() const;The joint's item uuid.
Returns Uuid
Lua: Joint:getShapeUuid
Vec3 worldPosition() const;Position and rotation, in the world / on the body.
Returns Vec3
Lua: Joint:getWorldPosition
Quat worldRotation() const;Position and rotation, in the world / on the body.
Returns Quat
Lua: Joint:getWorldRotation
Vec3 localPosition() const;Position and rotation, in the world / on the body.
Returns Vec3
Lua: Joint:getLocalPosition
Quat localRotation() const;Position and rotation, in the world / on the body.
Returns Quat
Lua: Joint:getLocalRotation
Vec3 xAxis() const;The joint's local axes in world space.
Returns Vec3
Lua: Joint:getXAxis
Vec3 yAxis() const;The joint's local axes in world space.
Returns Vec3
Lua: Joint:getYAxis
Vec3 zAxis() const;The joint's local axes in world space.
Returns Vec3
Lua: Joint:getZAxis
Vec3 boundingBox() const;Size in blocks.
Returns Vec3
Lua: Joint:getBoundingBox
Color color() const;Paint color.
Returns Color
Lua: Joint:getColor
void setColor(Color c) const;[server] Paints the joint.
Parameters
c(Color): The new color.
Lua: Joint:setColor
Sticky sticky() const;The sticky directions.
Returns Sticky
Vector<Shape> multiShapeShapes() const;The shapes and joints of its multi-shape item.
Returns Vector<Shape>
Vector<Joint> multiShapeJoints() const;The shapes and joints of its multi-shape item.
Returns Vector<Joint>
double angle() const;A bearing's angle in radians and angular speed.
Returns double
Lua: Joint:getAngle
double angularVelocity() const;A bearing's angle in radians and angular speed.
Returns double
Lua: Joint:getAngularVelocity
Vec3 angularVelocityVector() const;Angular velocity as a vector.
Returns Vec3
Lua: Joint:getAngularVelocityVector
double appliedImpulse() const;The impulse the motor applied last tick.
Returns double
Lua: Joint:getAppliedImpulse
bool bearingEnabled() const;True if the bearing turns freely.
Returns bool
Lua: Joint:getBearingEnabled
double length() const;A piston's current length.
Returns double
Lua: Joint:getLength
bool isReversed() const;True if the joint is reversed.
Returns bool
Lua: Joint:isReversed
void createBlock(const Uuid &uuid, Vec3 size, Vec3 localPosition, bool forceCreate = false) const;[server] Adds a block / part on the joint's far side.
Parameters
uuid(const Uuid &): The uuid of the shape.size(Vec3): The shape's size.localPosition(Vec3): The shape's local position.forceCreate(bool): Set true to force create the shape. (Defaults to true)
Lua: Joint:createBlock
void createPart(const Uuid &uuid, Vec3 localPosition, Vec3 zAxis, Vec3 xAxis, bool forceCreate = false) const;[server] Adds a block / part on the joint's far side.
Parameters
uuid(const Uuid &): The uuid of the shape.localPosition(Vec3): The shape's local position.zAxis(Vec3): The shape's local z direction.xAxis(Vec3): The shape's local x direction.forceCreate(bool): Set true to force create the shape. (Defaults to true)
Lua: Joint:createPart
void setMotorVelocity(double velocity, double maxImpulse) const;Bearings: spins at velocity with up to maxImpulse.
Parameters
velocity(double): The target velocity.maxImpulse(double): The max impulse.
Lua: Joint:setMotorVelocity
void setTargetAngle(double angle, double velocity, double maxImpulse) const;Bearings: turns to angle.
Parameters
angle(double): The target angle.velocity(double): The target velocity.maxImpulse(double): The max impulse.
Lua: Joint:setTargetAngle
void setTargetLength(double length, double velocity, double maxImpulse) const;[server] Pistons: extends to length.
Parameters
length(double): The target length.velocity(double): The target velocity.maxImpulse(double): The max impulse. (Defaults to impulse used in game)
Lua: Joint:setTargetLength
Character
Section titled "Character"A character: a player's body or a creature (Lua Character).
class Character : public atl::Objectint id() const;The character's id.
Returns int
Lua: Character:getId
Player player() const;The controlling player; empty for non-player characters.
Returns Player
Lua: Character:getPlayer
bool isPlayer() const;True for a player's character.
Returns bool
Lua: Character:isPlayer
World world() const;The world the character is in.
Returns World
Lua: Character:getWorld
Vec3 worldPosition() const;Position in the world.
Returns Vec3
Lua: Character:getWorldPosition
void setWorldPosition(Vec3 p) const;[server] Teleports the character.
Parameters
p(Vec3): The character's new world position.
Lua: Character:setWorldPosition
Vec3 velocity() const;Velocity.
Returns Vec3
Lua: Character:getVelocity
Vec3 direction() const;Look direction.
Returns Vec3
Lua: Character:getDirection
double mass() const;Mass, height and radius.
Returns double
Lua: Character:getMass
double height() const;Mass, height and radius.
Returns double
Lua: Character:getHeight
double radius() const;Mass, height and radius.
Returns double
Lua: Character:getRadius
Color color() const;Color.
Returns Color
Lua: Character:getColor
void setColor(Color c) const;[server] Paints the character.
Parameters
c(Color): The character color.
Lua: Character:setColor
bool isOnGround() const;Movement state.
Returns bool
Lua: Character:isOnGround
bool isCrouching() const;Movement state.
Returns bool
Lua: Character:isCrouching
bool isSprinting() const;Movement state.
Returns bool
Lua: Character:isSprinting
bool isSwimming() const;Movement state.
Returns bool
Lua: Character:isSwimming
bool isSeated() const;Movement state.
Returns bool
Lua: Character:isSeated
bool isTumbling() const;Movement state.
Returns bool
Lua: Character:isTumbling
bool isDowned() const;Movement state.
Returns bool
Lua: Character:isDowned
void setTumbling(bool v) const;[server] Knocks the character over / lets it get up.
Parameters
v(bool): The tumbling state.
Lua: Character:setTumbling
void setDowned(bool v) const;[server] Downs the character or revives it.
Parameters
v(bool): The downed state.
Lua: Character:setDowned
void setMovementSpeedFraction(double f) const;Scales movement speed (1 is normal).
Parameters
f(double): The movement speed fraction.
Lua: Character:setMovementSpeedFraction
void setNameTag(StringView name, Optional<Color> color = atl::none) const;Shows a name tag above the character.
Parameters
name(StringView)color(Optional<Color>)
Lua: Character:setNameTag
void applyImpulse(Vec3 impulse) const;Pushes the character.
Parameters
impulse(Vec3)
Lua: sm.physics.applyImpulse
Uuid characterType() const;The character type's uuid.
Returns Uuid
Lua: Character:getCharacterType
Unit unit() const;The AI unit controlling the character, if any.
Returns Unit
Lua: Character:getUnit
Vec3 smoothViewDirection() const;The look direction, smoothed.
Returns Vec3
Lua: Character:getSmoothViewDirection
Vec3 surfaceNormal() const;The normal of the surface the character stands on.
Returns Vec3
Lua: Character:getSurfaceNormal
bool isDefaultColor() const;True if the character has its default color.
Returns bool
Lua: Character:isDefaultColor
bool isMoving() const;More movement state.
Returns bool
Lua: Character:isMoving
bool isAiming() const;More movement state.
Returns bool
Lua: Character:isAiming
bool isClimbing() const;More movement state.
Returns bool
Lua: Character:isClimbing
bool isLadderClimbing() const;More movement state.
Returns bool
Lua: Character:isLadderClimbing
bool isDiving() const;More movement state.
Returns bool
Lua: Character:isDiving
bool isFlying() const;More movement state.
Returns bool
Lua: Character:isFlying
bool isHovering() const;More movement state.
Returns bool
Lua: Character:isHovering
bool canSwim() const;True if the character type can swim.
Returns bool
Lua: Character:getCanSwim
void setSwimming(bool v) const;[server] Forces a movement state.
Parameters
v(bool): The swimming state.
Lua: Character:setSwimming
void setDiving(bool v) const;[server] Forces a movement state.
Parameters
v(bool): The diving state.
Lua: Character:setDiving
void setClimbing(bool v) const;[server] Forces a movement state.
Parameters
v(bool): The climbing state.
Lua: Character:setClimbing
void setFlying(bool v) const;[server] Forces a movement state.
Parameters
v(bool): The flying state.
Lua: Character:setFlying
void setHovering(bool v) const;[server] Forces a movement state.
Parameters
v(bool): The hovering state.
Lua: Character:setHovering
bool immovable() const;[server] Whether the character can be pushed.
Returns bool
Lua: Character:getImmovable
void setImmovable(bool v) const;[server] Makes the character immovable or movable.
Parameters
v(bool): Set immovable state.
Lua: Character:setImmovable
double moveSpeed() const;Base walking and sprinting speeds.
Returns double
Lua: Character:getMoveSpeed
double sprintSpeed() const;Base walking and sprinting speeds.
Returns double
Lua: Character:getSprintSpeed
double currentMovementSpeed() const;The current movement speed.
Returns double
Lua: Character:getCurrentMovementSpeed
double movementSpeedFraction() const;The movement speed scale.
Returns double
Lua: Character:getMovementSpeedFraction
double jumpSpeedFraction() const;Reads / writes the jump height scale.
Returns double
Lua: Character:getJumpSpeedFraction
void setJumpSpeedFraction(double f) const;Reads / writes the jump height scale.
Parameters
f(double): The jump speed fraction.
Lua: Character:setJumpSpeedFraction
double movementNoiseRadius() const;How far the character's movement can be heard by AI.
Returns double
Lua: Character:getCurrentMovementNoiseRadius
void setMovementEffects(StringView effectSetPath) const;Sets the effect set used for footsteps and other movement sounds.
Parameters
effectSetPath(StringView): The effect set filepath.
Lua: Character:setMovementEffects
Interactable lockingInteractable() const;The interactable / harvestable the character is locked to (e.g. a seat or ladder), and setting it. The setters return true on success.
Returns Interactable
Lua: Character:getLockingInteractable
bool setLockingInteractable(const Interactable &i) const;The interactable / harvestable the character is locked to (e.g. a seat or ladder), and setting it. The setters return true on success.
Parameters
i(const Interactable &): The interactable.
Returns bool
Lua: Character:setLockingInteractable
Harvestable lockingHarvestable() const;The interactable / harvestable the character is locked to (e.g. a seat or ladder), and setting it. The setters return true on success.
Returns Harvestable
Lua: Character:getLockingHarvestable
bool setLockingHarvestable(const Harvestable &h) const;The interactable / harvestable the character is locked to (e.g. a seat or ladder), and setting it. The setters return true on success.
Parameters
h(const Harvestable &): The harvestable.
Returns bool
Lua: Character:setLockingHarvestable
Vec3 tumblingWorldPosition() const;The tumbling (ragdoll) body's position, rotation, velocities and size.
Returns Vec3
Lua: Character:getTumblingWorldPosition
Quat tumblingWorldRotation() const;The tumbling (ragdoll) body's position, rotation, velocities and size.
Returns Quat
Lua: Character:getTumblingWorldRotation
Vec3 tumblingLinearVelocity() const;The tumbling (ragdoll) body's position, rotation, velocities and size.
Returns Vec3
Lua: Character:getTumblingLinearVelocity
Vec3 tumblingAngularVelocity() const;The tumbling (ragdoll) body's position, rotation, velocities and size.
Returns Vec3
Lua: Character:getTumblingAngularVelocity
Vec3 tumblingExtent() const;The tumbling (ragdoll) body's position, rotation, velocities and size.
Returns Vec3
Lua: Character:getTumblingExtent
void applyTumblingImpulse(Vec3 impulse, Optional<Vec3> offset = atl::none) const;Pushes the tumbling body.
Parameters
impulse(Vec3): The impulse.offset(Optional<Vec3>): The offset from the center point. (Defaults to no offset)
Lua: Character:applyTumblingImpulse
void setAllowTumbleAnimations(bool allow) const;Whether tumbling plays animations.
Parameters
allow(bool): The state.
Lua: Character:setAllowTumbleAnimations
Value publicData() const;[server] Data other server scripts can read.
Returns Value
Lua: Character:getPublicData
void setPublicData(const Value &t) const;[server] Sets data other server scripts can read.
Parameters
t(const Value &): The public data.
Lua: Character:setPublicData
Value clientPublicData() const;[client] Data other client scripts can read.
Returns Value
Lua: Character:getClientPublicData
void setClientPublicData(const Value &t) const;[client] Sets data other client scripts can read.
Parameters
t(const Value &): The client public data.
Lua: Character:setClientPublicData
Vec3 tpBonePosition(StringView bone) const;A bone's third person position / rotation.
Parameters
bone(StringView): The joint name.
Returns Vec3
Lua: Character:getTpBonePos
Quat tpBoneRotation(StringView bone) const;A bone's third person position / rotation.
Parameters
bone(StringView): The joint name.
Returns Quat
Lua: Character:getTpBoneRot
Vector<ActiveAnimation> activeAnimations() const;The animations playing now.
Returns Vector<ActiveAnimation>
Lua: Character:getActiveAnimations
AnimationInfo animationInfo(StringView name) const;Information about an animation.
Parameters
name(StringView): The name.
Returns AnimationInfo
Lua: Character:getAnimationInfo
void updateAnimation(StringView name, double time, Optional<double> weight = atl::none, bool additive = false) const;Plays an animation at time with an optional blend weight.
Parameters
name(StringView): The animation name.time(double): The time.weight(Optional<double>): The weight. Defaults to -1.0. (Optional)additive(bool): Whether the animation will be added to the default animation. Defaults to false. (Optional)
Lua: Character:updateAnimation
bool hasActiveOverrideAnimation() const;True while an override animation plays.
Returns bool
Lua: Character:hasActiveOverrideAnimation
void setMovementWeights(double lower, double upper) const;Blend weights of the lower and upper body movement animations.
Parameters
lower(double): The lower weight.upper(double): The upper weight.
Lua: Character:setMovementWeights
void onAnimation(StringView name, double time, atl::Function<void()> fn) const;Calls fn when animation name reaches time.
Parameters
name(StringView): The name of the animation.time(double): The required time that will have elapsed in the animation when the callback is triggered.fn(atl::Function<void ()>): The name of the Lua function to bind.
Lua: Character:bindAnimationCallback
void removeAnimationCallbacks() const;Removes every onAnimation callback.
Lua: Character:removeAnimationCallbacks
bool hasGraphics() const;True once the character's graphics are loaded.
Returns bool
Lua: Character:hasGraphics
bool isVisible() const;Visibility.
Returns bool
Lua: Character:isVisible
void setVisible(bool visible) const;Visibility.
Parameters
visible(bool): Whether the character should be visible.
Lua: Character:setVisible
void addRenderable(StringView rend) const;Adds / removes a renderable on the character.
Parameters
rend(StringView): The renderable path.
Lua: Character:addRenderable
void removeRenderable(StringView rend) const;Adds / removes a renderable on the character.
Parameters
rend(StringView): The renderable path.
Lua: Character:removeRenderable
void overrideRenderables(const Vector<String> &rends) const;Replaces the character's renderables.
Parameters
rends(const Vector<String> &): An array of renderable file paths to override with.
Lua: Character:overrideRenderableList
double glowMultiplier() const;Reads / writes the glow multiplier.
Returns double
Lua: Character:getGlowMultiplier
void setGlowMultiplier(double v) const;Reads / writes the glow multiplier.
Parameters
v(double): The glow multiplier (0.0 - 1.0).
Lua: Character:setGlowMultiplier
void setUpDirection(Vec3 up) const;Sets which way is up for the character.
Parameters
up(Vec3): The direction.
Lua: Character:setUpDirection
Player
Section titled "Player"A connected player (Lua Player).
class Player : public atl::Objectint id() const;The player's id.
Returns int
Lua: Player:getId
String name() const;The player's display name.
Returns String
Lua: Player:getName
Character character() const;The player's current character.
Returns Character
Lua: Player:getCharacter
Container inventory() const;The player's inventory and hotbar.
Returns Container
Lua: Player:getInventory
Container hotbar() const;The player's inventory and hotbar.
Returns Container
Lua: Player:getHotbar
bool isMale() const;The character's body type.
Returns bool
Lua: Player:isMale
bool isFemale() const;The character's body type.
Returns bool
Lua: Player:isFemale
Value publicData() const;[server] Data other scripts can read.
Returns Value
Lua: Player:getPublicData
void setPublicData(const Value &t) const;[server] Sets data other scripts can read.
Parameters
t(const Value &): The public data.
Lua: Player:setPublicData
Value clientPublicData() const;[client] Data other client scripts can read.
Returns Value
Lua: Player:getClientPublicData
void setClientPublicData(const Value &t) const;[client] Sets data other client scripts can read.
Parameters
t(const Value &): The client public data.
Lua: Player:setClientPublicData
bool isActive() const;True until the player has left.
Returns bool
Lua: Player:isActive
Uuid currentToolUuid() const;The uuid of the tool the player holds.
Returns Uuid
Lua: Player:getCurrentToolUuid
Uuid customizationUuid(int index) const;[server] The uuid of customization slot index.
Parameters
index(int)
Returns Uuid
Lua: Player:getCustomizationUuid
void setCharacter(const Character &c) const;[server] Gives the player a character.
Parameters
c(const Character &): The character.
Lua: Player:setCharacter
void sendCharacterEvent(StringView event) const;[server] Fires client_onEvent on the player's character.
Parameters
event(StringView): The event to send
Lua: Player:sendCharacterEvent
Container carry() const;The container of the item the player carries.
Returns Container
Lua: Player:getCarry
Color carryColor() const;[server] The carried item's color.
Returns Color
Lua: Player:getCarryColor
Value carryData() const;[server] Data of the carried item.
Returns Value
Lua: Player:getCarryData
void setCarryData(const Value &t) const;[server] Sets the carried item's data.
Parameters
t(const Value &)
Lua: Player:setCarryData
void placeLift(const Vector<Body> &creation, Vec3 position, int level, int rotation) const;[server] Places the player's lift, carrying creation, at level with rotation (0..3).
Parameters
creation(const Vector<Body> &)position(Vec3): The lift position.level(int): The lift level.rotation(int): The rotation of the creation on the lift.
Lua: Player:placeLift
void removeLift() const;[server] Removes the player's lift.
Lua: Player:removeLift
An item stack: uuid and quantity.
struct ItemUuid uuid;int quantity = 0;bool empty() const;True for no item.
Returns bool
Container
Section titled "Container"An item container: inventory, chest, hotbar... (Lua Container).
class Container : public atl::Objectint size() const;Number of slots.
Returns int
Lua: Container:getSize
Item item(int slot) const;The item in a slot.
Parameters
slot(int): The slot.
Returns Item
Lua: Container:getItem
bool isEmpty() const;True if every / no slot is free.
Returns bool
Lua: Container:isEmpty
bool isFull() const;True if every / no slot is free.
Returns bool
Lua: Container:isFull
bool canCollect(const Uuid &item, int quantity) const;True if quantity of item fit / can be taken.
Parameters
item(const Uuid &): The uuid of the item.quantity(int): The number of items.
Returns bool
Lua: Container:canCollect
bool canSpend(const Uuid &item, int quantity) const;True if quantity of item fit / can be taken.
Parameters
item(const Uuid &): The uuid of the item.quantity(int): The number of items.
Returns bool
Lua: Container:canSpend
bool canCollectAll(const Vector<Item> &items) const;True if all of these items fit at once.
Parameters
items(const Vector<Item> &)
Returns bool
Lua: Container:canCollectAll
int count(const Uuid &item) const;Total quantity of an item.
Parameters
item(const Uuid &)
Returns int
Lua: sm.container.totalQuantity
int maxStackSize() const;Largest stack per slot.
Returns int
Lua: Container:getMaxStackSize
Vector<Uuid> uniqueItems() const;Each item type present, once.
Returns Vector<Uuid>
Lua: sm.container.uniqueItemUuids
Vector<Uuid> itemUuids() const;Every slot's uuid / quantity, in slot order.
Returns Vector<Uuid>
Lua: sm.container.itemUuid
Vector<int> quantities() const;Every slot's uuid / quantity, in slot order.
Returns Vector<int>
Lua: sm.container.quantity
Item firstItem() const;The first non-empty slot's item.
Returns Item
Lua: sm.container.getFirstItem
int revision() const;Network revision, bumped on every change.
Returns int
Lua: Container:getRevision
bool hasChanged(int tick) const;[server] True if the container changed after tick.
Parameters
tick(int): The tick.
Returns bool
Lua: Container:hasChanged
bool allowCollect() const;[server] Whether items can be put in / taken out.
Returns bool
Lua: Container:getAllowCollect
bool allowSpend() const;[server] Whether items can be put in / taken out.
Returns bool
Lua: Container:getAllowSpend
void moveAllToCarry(const Player &player, Color color) const;[server] Moves everything into player's carry container, painted color.
Parameters
player(const Player &)color(Color)
Lua: sm.container.moveAllToCarryContainer
int collect(const Uuid &item, int quantity, bool mustCollectAll = false) const;[server] Adds / removes items; returns how many were moved. Use inside container::transaction.
Parameters
item(const Uuid &): The uuid of the item.quantity(int): The number of items.mustCollectAll(bool): Must collect all items for the transaction to be valid. Defaults to true. (Optional)
Returns int
Lua: Container:collect
int spend(const Uuid &item, int quantity, bool mustSpendAll = true) const;[server] Adds / removes items; returns how many were moved. Use inside container::transaction.
Parameters
item(const Uuid &)quantity(int)mustSpendAll(bool)
Returns int
Lua: sm.container.spend
int collectToSlot(int slot, const Uuid &item, int quantity, bool mustCollectAll = true) const;[server] Adds to / takes from one slot.
Parameters
slot(int)item(const Uuid &)quantity(int)mustCollectAll(bool)
Returns int
Lua: sm.container.collectToSlot
int spendFromSlot(int slot, const Uuid &item, int quantity, bool mustSpendAll = true) const;[server] Adds to / takes from one slot.
Parameters
slot(int)item(const Uuid &)quantity(int)mustSpendAll(bool)
Returns int
Lua: sm.container.spendFromSlot
bool swap(const Container &other, int fromSlot, int toSlot) const;[server] Swaps slots with another container.
Parameters
other(const Container &)fromSlot(int)toSlot(int)
Returns bool
Lua: sm.container.swap
void moveAllTo(const Container &other) const;[server] Moves everything to another container.
Parameters
other(const Container &)
Lua: sm.container.moveAll
bool setItem(int slot, const Uuid &item, int quantity) const;[server] Direct edits, outside transactions: set a slot, clear, resize, and allow collecting / spending.
Parameters
slot(int)item(const Uuid &)quantity(int)
Returns bool
Lua: Container:setItem
void clear() const;[server] Direct edits, outside transactions: set a slot, clear, resize, and allow collecting / spending.
Lua: Container:clear
void resize(int size, Optional<int> stackSize = atl::none) const;[server] Direct edits, outside transactions: set a slot, clear, resize, and allow collecting / spending.
Parameters
size(int): The new size of the container.stackSize(Optional<int>): The stack size. Defaults to maximum possible stack size(65535).
Lua: Container:resize
void setAllowCollect(bool allow) const;[server] Direct edits, outside transactions: set a slot, clear, resize, and allow collecting / spending.
Parameters
allow(bool): True if the container can collect.
Lua: Container:setAllowCollect
void setAllowSpend(bool allow) const;[server] Direct edits, outside transactions: set a slot, clear, resize, and allow collecting / spending.
Parameters
allow(bool): True if the container can spend.
Lua: Container:setAllowSpend
void setFilters(const Vector<Uuid> &allowed) const;[server] Only these items may be put in (empty: anything).
Parameters
allowed(const Vector<Uuid> &)
Lua: Container:setFilters
void onTransaction(atl::Function<void()> fn) const;[server] Runs after every transaction that changed this container.
Parameters
fn(atl::Function<void ()>)
Lua: Container:bindOnTransaction
A world: terrain, cells and everything in them (Lua World).
class World : public atl::Objectint id() const;The world's id.
Returns int
Lua: World:getId
bool isIndoor() const;True for an indoor world.
Returns bool
Lua: World:isIndoor
void destroy() const;[server] Destroys the world.
Lua: World:destroy
CellBounds cellBounds() const;Reads the world's cell bounds.
Returns CellBounds
bool isCellInBounds(int x, int y) const;True if the cell is inside the bounds.
Parameters
x(int): The X coordinate of the cell.y(int): The Y coordinate of the cell.
Returns bool
Lua: World:isCellInBounds
bool isCellLoadedServer(int x, int y) const;[server] True if the cell is loaded on the server.
Parameters
x(int): The cell X value.y(int): The cell Y value.
Returns bool
Lua: World:isCellLoadedServer
bool isCellLoadedClient(int x, int y) const;[client] True if the cell is loaded on this client.
Parameters
x(int): The cell X value.y(int): The cell Y value.
Returns bool
Lua: World:isCellLoadedClient
void loadCell(int x, int y, const Player &player = {}, atl::Function<void(int, int)> onLoaded = {}) const;[server] Loads a cell until player (if any) steps into it; onLoaded(x, y) runs when it's ready.
Parameters
x(int)y(int)player(const Player &)onLoaded(atl::Function<void (int, int)>)
Lua: World:loadCell
LoadCellHandle loadCellWithHandle(int x, int y, atl::Function<void(int, int)> onLoaded = {}) const;Keeps a cell loaded until the handle is released (or garbage collected).
Parameters
x(int)y(int)onLoaded(atl::Function<void (int, int)>)
Returns LoadCellHandle
Lua: World:loadCellWithHandle
LoadCellHandle loadNavMeshWithHandle(int x, int y, atl::Function<void(int, int)> onLoaded = {}) const;[server] Same, with its nav mesh.
Parameters
x(int)y(int)onLoaded(atl::Function<void (int, int)>)
Returns LoadCellHandle
Lua: World:loadNavMeshWithHandle
void reloadCell(int x, int y, atl::Function<void(int, int, bool)> onDone = {}) const;Reloads a cell. onDone(x, y, reloaded) gets false if the cell wasn't active.
Parameters
x(int)y(int)onDone(atl::Function<void (int, int, bool)>)
Lua: World:reloadCell
void setTerrainScriptData(const Value &data) const;Data for the terrain generation script (Create's data).
Parameters
data(const Value &): Any data, available to the terrain generation script as parameter 6 in the create callback.
Lua: World:setTerrainScriptData
Value zoneId(Vec3 position) const;The zone id at a position (nil if none).
Parameters
position(Vec3): The position.
Returns Value
Lua: World:getZoneId
void setLightColorOverride(Color c) const;[server] Overrides every light controller's color in the world.
Parameters
c(Color): The override color.
Lua: World:setLightColorOverride
void clearLightColorOverride() const;[server] Removes the light color override.
Lua: World:clearLightColorOverride
VoxelMaterial dominantMaterialInSphere(Vec3 position, double radius) const;The most common voxel material in a sphere / capsule.
Parameters
position(Vec3)radius(double)
Returns VoxelMaterial
VoxelMaterial dominantMaterialInCapsule(Vec3 position, double radius, double height) const;The most common voxel material in a sphere / capsule.
Parameters
position(Vec3)radius(double)height(double)
Returns VoxelMaterial
VoxelMaterial voxelMaterialAt(Vec3 worldPosition) const;The voxel material at a point.
Parameters
worldPosition(Vec3)
Returns VoxelMaterial
WeightedDensity weightedVoxelDensityAt(Vec3 point) const;Reads the interpolated voxel density at a point.
Parameters
point(Vec3)
Returns WeightedDensity
bool isVoxelTerrainPointClear(Vec3 referencePosition, Vec3 testPosition) const;True if testPosition is free of voxel terrain, as seen from referencePosition.
Parameters
referencePosition(Vec3): The reference position (e.g. character position).testPosition(Vec3): The position to test for voxel coverage (e.g. shape center).
Returns bool
Lua: World:isVoxelTerrainPointClear
void sphereVoxelDensityAddition(Vec3 position, double radius, int material, const Player &player = {}) const;[server] Adds voxels in a sphere.
Parameters
position(Vec3): The world position of the sphere.radius(double): The radius of the sphere.material(int): The material to add [0-7].player(const Player &): The player who constructed. (Optional)
Lua: World:sphereVoxelDensityAddition
void sphereVoxelDensitySubtraction(Vec3 position, double radius, Optional<int> filter = atl::none, Optional<double> strength = atl::none, atl::Function<void(Value data)> onDone = {}) const;[server] Removes voxels in a sphere. filter is sm.world.voxelFilter; onDone(data) gets { remDensities, avgPositions }.
Parameters
position(Vec3)radius(double)filter(Optional<int>)strength(Optional<double>)onDone(atl::Function<void (Value)>)
Lua: World:sphereVoxelDensitySubtraction
void voxelDensityAddition(Vec3 position, Vec3 surfaceNormal, double maxDistance, int targetDensity, int material, Optional<int> filter = atl::none, const Player &player = {}) const;[server] Adds voxels along surfaceNormal up to maxDistance.
Parameters
position(Vec3): The voxel world position.surfaceNormal(Vec3): The surface normal.maxDistance(double): The maximum distance from position that can be modified.targetDensity(int): The target density to add.material(int): The material to add [0-7].filter(Optional<int>): The materials the shape can modify. (Seesm.world.voxelFilter). (Defaults to sm.world.voxelFilter.all)player(const Player &): The player who constructed. (Optional)
Lua: World:voxelDensityAddition
void voxelDensitySubtraction(Vec3 position, Vec3 direction, double radius, int targetDensity, Optional<int> filter = atl::none, bool destructionEffect = true, atl::Function<void(Value data)> onDone = {}) const;[server] Removes voxels around the line position + direction within radius.
Parameters
position(Vec3)direction(Vec3)radius(double)targetDensity(int)filter(Optional<int>)destructionEffect(bool)onDone(atl::Function<void (Value)>)
Lua: World:voxelDensitySubtraction
void voxelDensitySubtraction(Vec3 position, Vec3 direction, double radius, const Vector<int> &targetDensities, Optional<int> filter = atl::none, bool destructionEffect = true, atl::Function<void(Value data)> onDone = {}) const;[server] Same, with a target density per material.
Parameters
position(Vec3)direction(Vec3)radius(double)targetDensities(const Vector<int> &)filter(Optional<int>)destructionEffect(bool)onDone(atl::Function<void (Value)>)
Lua: World:voxelDensitySubtraction
void setMiningConfig(const Value &config) const;[server] Mining loot config (see WorldClass::server_onMining).
Parameters
config(const Value &)
Lua: World:setMiningConfig
CellBounds
Section titled "CellBounds"The range of cell coordinates the world covers.
struct CellBoundsint minX = 0, maxX = 0, minY = 0, maxY = 0;VoxelMaterial
Section titled "VoxelMaterial"A voxel material and density, and (for dominantMaterial queries) a position.
struct VoxelMaterialint material = 0;int density = 0;Vec3 position;WeightedDensity
Section titled "WeightedDensity"Voxel density and its gradient at a point.
struct WeightedDensitydouble density = 0;Vec3 gradient;Harvestable
Section titled "Harvestable"A tree, rock, plant or kinematic object (Lua Harvestable).
class Harvestable : public atl::Objectint id() const;The harvestable's id.
Returns int
Lua: Harvestable:getId
Uuid uuid() const;Its item uuid, name and type.
Returns Uuid
Lua: Harvestable:getUuid
String name() const;Its item uuid, name and type.
Returns String
Lua: Harvestable:getName
String type() const;Its item uuid, name and type.
Returns String
Lua: Harvestable:getType
Vec3 position() const;Position, rotation and scale.
Returns Vec3
Lua: Harvestable:getPosition
Quat rotation() const;Position, rotation and scale.
Returns Quat
Lua: Harvestable:getRotation
Vec3 scale() const;Position, rotation and scale.
Returns Vec3
Lua: Harvestable:getScale
Color color() const;Color.
Returns Color
Lua: Harvestable:getColor
void setColor(Color c) const;Paints the harvestable.
Parameters
c(Color): The color.
Lua: Harvestable:setColor
void destroy() const;[server] Destroys the harvestable.
Lua: Harvestable:destroy
World world() const;The world it's in.
Returns World
Lua: Harvestable:getWorld
void setPosition(Vec3 p) const;Moves / rotates a kinematic harvestable.
Parameters
p(Vec3): The position.
Lua: Harvestable:setPosition
void setRotation(Quat q) const;Moves / rotates a kinematic harvestable.
Parameters
q(Quat): The rotation.
Lua: Harvestable:setRotation
Vec3 velocity() const;Velocity and angular velocity.
Returns Vec3
Lua: Harvestable:getVelocity
Vec3 angularVelocity() const;Velocity and angular velocity.
Returns Vec3
Lua: Harvestable:getAngularVelocity
double mass() const;Mass in kilograms.
Returns double
Lua: Harvestable:getMass
String material() const;The physics material name and id.
Returns String
Lua: Harvestable:getMaterial
int materialId() const;The physics material name and id.
Returns int
Lua: Harvestable:getMaterialId
Aabb aabb() const;World-space / local-space bounds.
Returns Aabb
Aabb localAabb() const;World-space / local-space bounds.
Returns Aabb
Vec3 transformPoint(Vec3 worldPoint) const;World point to local / local point to world / world direction to local.
Parameters
worldPoint(Vec3): The world point.
Returns Vec3
Lua: Harvestable:transformPoint
Vec3 transformLocalPoint(Vec3 localPoint) const;World point to local / local point to world / world direction to local.
Parameters
localPoint(Vec3): The local point.
Returns Vec3
Lua: Harvestable:transformLocalPoint
Vec3 transformDirection(Vec3 worldDir) const;World point to local / local point to world / world direction to local.
Parameters
worldDir(Vec3): The world direction.
Returns Vec3
Lua: Harvestable:transformDirection
bool isKinematic() const;True for a kinematic (scripted, movable) harvestable.
Returns bool
Lua: Harvestable:isKinematic
bool isCellKinematic() const;True for a kinematic placed by a cell (vs. created from a script).
Returns bool
Lua: Harvestable:isCellKinematic
double initialHash() const;Identifies a kinematic across reloads (harvestables::byInitialHash).
Returns double
Lua: Harvestable:getInitialHash
Value data() const;The script data from the harvestable's definition.
Returns Value
Lua: Harvestable:getData
void setParams(const Value &data) const;[server] Sets the params of a harvestable created from a script.
Parameters
data(const Value &): The param data.
Lua: Harvestable:setParams
Value publicData() const;[server] Data other scripts can read.
Returns Value
Lua: Harvestable:getPublicData
void setPublicData(const Value &t) const;[server] Sets data other scripts can read.
Parameters
t(const Value &): The public data.
Lua: Harvestable:setPublicData
Value clientPublicData() const;[client] Data other client scripts can read.
Returns Value
Lua: Harvestable:getClientPublicData
void setClientPublicData(const Value &t) const;[client] Sets data other client scripts can read.
Parameters
t(const Value &): The client public data.
Lua: Harvestable:setClientPublicData
bool hasSeat() const;Seats (kinematics with a seat component): whether there is one, who sits in it, and seating a character.
Returns bool
Lua: Harvestable:hasSeat
Character seatCharacter() const;Seats (kinematics with a seat component): whether there is one, who sits in it, and seating a character.
Returns Character
Lua: Harvestable:getSeatCharacter
void setSeatCharacter(const Character &c) const;Seats (kinematics with a seat component): whether there is one, who sits in it, and seating a character.
Parameters
c(const Character &): The character.
Lua: Harvestable:setSeatCharacter
void applyShakeImpulse(double shake) const;[client] Shakes the harvestable visually.
Parameters
shake(double): The shake impulse value.
Lua: Harvestable:applyShakeImpulse
int uvFrameIndex() const;[client] Reads / writes the UV frame.
Returns int
Lua: Harvestable:getUvFrameIndex
void setUvFrameIndex(int index) const;[client] Reads / writes the UV frame.
Parameters
index(int): The index.
Lua: Harvestable:setUvFrameIndex
double poseWeight(int index) const;[client] Reads / writes an animation pose weight.
Parameters
index(int): The index.
Returns double
Lua: Harvestable:getPoseWeight
void setPoseWeight(int index, double weight) const;[client] Reads / writes an animation pose weight.
Parameters
index(int): The index.weight(double): The pose weight.
Lua: Harvestable:setPoseWeight
void setSubMeshVisible(StringView name, bool visible) const;[client] Shows or hides one / every sub-mesh.
Parameters
name(StringView): Name of the submesh.visible(bool): True if the submesh should be visible.
Lua: Harvestable:setSubMeshVisible
void setAllSubMeshVisible(bool visible) const;[client] Shows or hides one / every sub-mesh.
Parameters
visible(bool): True if the submeshes should be visible.
Lua: Harvestable:setAllSubMeshVisible
Network
Section titled "Network"A script's network channel between its server and client sides (self.network).
class Network : public atl::Objectstatic constexpr size_t kPacketLimit = kNetworkPacketLimit;Same as kNetworkPacketLimit.
template <class T = atl::Nil> void sendToServer(StringView method, const T &data = {}) const;[client] Calls method(data, sender) on the server side.
Parameters
method(StringView): The server function name.data(const atl::Value &): Optional arguments to be sent to the server.
Lua: Network:sendToServer
template <class T = atl::Nil> void sendToClients(StringView method, const T &data = {}) const;[server] Calls method(data) on every client.
Parameters
method(StringView): The client function name.data(const atl::Value &): Optional arguments to be sent to the client.
Lua: Network:sendToClients
template <class T = atl::Nil> void sendToClient(const Player &player, StringView method, const T &data = {}) const;[server] Calls method(data) on one player's client.
Parameters
player(const Player &): The client player (or the host).method(StringView): The client function name.data(const atl::Value &): Optional arguments to be sent to the client.
Lua: Network:sendToClient
template <class T> void setClientData(const T &data, int channel = 1) const;[server] Syncs data to client_onClientDataUpdate on every client, including players who join later.
Parameters
data(const atl::Value &): Persistent data to be synchronized with existing and new clients.channel(int): Client data channel, 1 to 4 (Optional) (Defaults to 1)
Lua: Network:setClientData
Effect
Section titled "Effect"A visual or sound effect (Lua Effect).
class Effect : public atl::Objectvoid start() const;Starts playing.
Lua: Effect:start
void stop() const;Stops, letting the effect finish / stops at once.
Lua: Effect:stop
void stopImmediate() const;Stops, letting the effect finish / stops at once.
Lua: Effect:stopImmediate
void destroy() const;Destroys the effect.
Lua: Effect:destroy
bool isPlaying() const;True while playing.
Returns bool
Lua: Effect:isPlaying
bool isDone() const;True once finished.
Returns bool
Lua: Effect:isDone
void setPosition(Vec3 p) const;Sets position, rotation, velocity and scale.
Parameters
p(Vec3): The position.
Lua: Effect:setPosition
void setRotation(Quat q) const;Sets position, rotation, velocity and scale.
Parameters
q(Quat): The rotation.
Lua: Effect:setRotation
void setVelocity(Vec3 v) const;Sets position, rotation, velocity and scale.
Parameters
v(Vec3): The velocity.
Lua: Effect:setVelocity
void setScale(Vec3 s) const;Sets position, rotation, velocity and scale.
Parameters
s(Vec3): The scale.
Lua: Effect:setScale
void setOffsetPosition(Vec3 p) const;Offset from the host.
Parameters
p(Vec3): The relative offset position.
Lua: Effect:setOffsetPosition
void setOffsetRotation(Quat q) const;Offset from the host.
Parameters
q(Quat): The relative offset rotation.
Lua: Effect:setOffsetRotation
template <class T> void setParameter(StringView name, const T &value) const;Sets an effect parameter.
Parameters
name(StringView): The name.value(const T &): The effect parameter value.
Lua: Effect:setParameter
void setAutoPlay(bool on) const;Whether the effect restarts by itself when done.
Parameters
on(bool)
Lua: Effect:setAutoPlay
int id() const;The effect's id.
Returns int
Lua: Effect:getId
Vec3 worldPosition() const;[client] The effect's position in the world.
Returns Vec3
Lua: Effect:getWorldPosition
void setStartStopDistance(double startDistance, double stopDistance) const;Starts when the camera is within startDistance, stops beyond stopDistance.
Parameters
startDistance(double)stopDistance(double)
Lua: Effect:setStartStopDistance
template <class Host> void setHost(const Host &host, StringView bone = {}) const;[client] Attaches to a Shape, Interactable, Character or Harvestable, optionally to a bone.
Parameters
host(const Host &): The pHarvestable the effect is attached to.bone(StringView): The bone name to attach effect to. (Defaults to not attached to a bone) (Optional)
Lua: Effect:setHost
bool hasHost() const;[client] True if attached to a host.
Returns bool
Lua: Effect:hasHost
void detach() const;[client] Detaches from the host.
Lua: Effect:detach
void setDetachOnHostDestroy(bool detach) const;[client] Whether to detach instead of being destroyed with the host.
Parameters
detach(bool): If the effect should automatically detach from the host or not.
Lua: Effect:setDetachOnHostDestroy
void setHostAxisIgnore(int axis) const;[client] A rotation axis (sm.effect.axis...) that hosted effects ignore.
Parameters
axis(int): The rotation axis.
Lua: Effect:setHostAxisIgnore
void setWorld(const World &w) const;[client] The world the effect plays in.
Parameters
w(const World &): The world. Defaults to world from script context. (optional)
Lua: Effect:setWorld
void setWorldAny() const;[client] Plays in every world, for global sounds.
Lua: Effect:setWorldAny
void setTimeOfDay(bool enabled, double startTime, double endTime, bool inverse = false) const;[client] Only active between startTime and endTime (0..1 time of day), or outside it if inverse.
Parameters
enabled(bool): Time of day enabled.startTime(double): Start normalized time of day.endTime(double): End normalized time of day.inverse(bool): If true, period between start-end becomes inactive time.
Lua: Effect:setTimeOfDay
bool isBreakSustaining() const;[client] Sustained sounds: whether the sound is finishing, and letting it finish before it's destroyed.
Returns bool
Lua: Effect:isBreakSustaining
void stopBreakSustain() const;[client] Sustained sounds: whether the sound is finishing, and letting it finish before it's destroyed.
Lua: Effect:stopBreakSustain
bool hasActiveCamera() const;[client] True while the effect controls the camera.
Returns bool
Lua: Effect:hasActiveCamera
CameraData cameraData() const;[client] Reads the effect's camera.
Returns CameraData
Lua: Effect:getCameraData
void bindEventClientCallback(const Value ¶ms = {}, const Value &reference = {}) const;[client] Effect event callbacks: reference is the script table that receives them
(default: the running script), params is passed through.
Parameters
params(const Value &): Parameter object passed to the callback. (Optional)reference(const Value &): Table to receive the callback. (Optional)
Lua: Effect:bindEventClientCallback
void bindEventServerCallback(const Value ¶ms = {}, const Value &reference = {}) const;[client] Effect event callbacks: reference is the script table that receives them
(default: the running script), params is passed through.
Parameters
params(const Value &): Parameter object passed to the callback. (Optional)reference(const Value &): Table to receive the callback. (Optional)
Lua: Effect:bindEventServerCallback
void clearClientEventCallback() const;Removes the client / server event callbacks.
Lua: Effect:clearClientEventCallback
void clearServerEventCallback() const;Removes the client / server event callbacks.
Lua: Effect:clearServerEventCallback
CameraData
Section titled "CameraData"[client] The camera an effect controls (camera effects).
struct CameraDatabool active = false, hasBlendIn = false, hasBlendOut = false;Vec3 position;Quat rotation;double fov = 0;A tool a player holds (Lua Tool).
class Tool : public atl::Objectint id() const;The tool's id.
Returns int
Lua: Tool:getId
Uuid uuid() const;The tool's item uuid.
Returns Uuid
Lua: Tool:getUuid
Player owner() const;The player holding it.
Returns Player
Lua: Tool:getOwner
bool isLocal() const;True on the owner's client.
Returns bool
Lua: Tool:isLocal
bool isEquipped() const;True while equipped.
Returns bool
Lua: Tool:isEquipped
bool isInFirstPersonView() const;The owner's view and movement state.
Returns bool
Lua: Tool:isInFirstPersonView
bool isCrouching() const;The owner's view and movement state.
Returns bool
Lua: Tool:isCrouching
bool isSprinting() const;The owner's view and movement state.
Returns bool
Lua: Tool:isSprinting
bool isOnGround() const;The owner's view and movement state.
Returns bool
Lua: Tool:isOnGround
Vec3 position() const;Position and aim direction of the tool.
Returns Vec3
Lua: Tool:getPosition
Vec3 direction() const;Position and aim direction of the tool.
Returns Vec3
Lua: Tool:getDirection
Vec3 smoothDirection() const;Aim direction, smoothed.
Returns Vec3
Lua: Tool:getSmoothDirection
Vec3 movementVelocity() const;The owner's movement velocity.
Returns Vec3
Lua: Tool:getMovementVelocity
double movementSpeedFraction() const;The owner's movement speed scale.
Returns double
Lua: Tool:getMovementSpeedFraction
void setFpRenderables(const Vector<String> &rends) const;[client] Sets the first / third person renderables (paths to .rend files) and their colors.
Parameters
rends(const Vector<String> &)
Lua: Tool:setFpRenderables
void setTpRenderables(const Vector<String> &rends) const;[client] Sets the first / third person renderables (paths to .rend files) and their colors.
Parameters
rends(const Vector<String> &)
Lua: Tool:setTpRenderables
void setFpColor(Color c) const;[client] Sets the first / third person renderables (paths to .rend files) and their colors.
Parameters
c(Color): The color.
Lua: Tool:setFpColor
void setTpColor(Color c) const;[client] Sets the first / third person renderables (paths to .rend files) and their colors.
Parameters
c(Color)
Lua: Tool:setTpColor
void updateAnimation(StringView name, double time, Optional<double> weight = atl::none) const;[client] Plays a third person animation; time is seconds into it.
Parameters
name(StringView)time(double)weight(Optional<double>)
Lua: Tool:updateAnimation
void updateFpAnimation(StringView name, double time, Optional<double> weight = atl::none, bool looping = false) const;[client] Plays a first person animation.
Parameters
name(StringView)time(double)weight(Optional<double>)looping(bool)
Lua: Tool:updateFpAnimation
void setMovementAnimation(StringView movement, StringView animation) const;[client] Replaces a movement animation (e.g. "idle") with one of the tool's.
Parameters
movement(StringView)animation(StringView)
Lua: Tool:setMovementAnimation
void setMovementSlowDown(bool slowDown) const;[client] Slows the owner down while held.
Parameters
slowDown(bool)
Lua: Tool:setMovementSlowDown
void setBlockSprint(bool block) const;[client] Prevents sprinting while held.
Parameters
block(bool): Whether the player's sprinting is blocked.
Lua: Tool:setBlockSprint
void setCrossHairAlpha(double alpha) const;[client] Crosshair alpha, color, type and spread.
Parameters
alpha(double): The alpha value for the crosshair.
Lua: Tool:setCrossHairAlpha
void setCrossHairColor(Color c) const;[client] Crosshair alpha, color, type and spread.
Parameters
c(Color): The color.
Lua: Tool:setCrossHairColor
void setCrossHairType(int type) const;[client] Crosshair alpha, color, type and spread.
Parameters
type(int): The type value for the crosshair.
Lua: Tool:setCrossHairType
void setDispersionFraction(double dispersion) const;[client] Crosshair alpha, color, type and spread.
Parameters
dispersion(double)
Lua: Tool:setDispersionFraction
void updateCamera(double distance, double fov, Vec3 offset, double weight) const;[client] Blends the camera toward a tool-specific view (aiming, ...).
Parameters
distance(double)fov(double)offset(Vec3)weight(double)
Lua: Tool:updateCamera
Vec3 fpBonePosition(StringView bone) const;[client] A bone's first / third person position.
Parameters
bone(StringView)
Returns Vec3
Lua: Tool:getFpBonePos
Vec3 tpBonePosition(StringView bone) const;[client] A bone's first / third person position.
Parameters
bone(StringView): The joint name.
Returns Vec3
Lua: Tool:getTpBonePos
Vec3 fpBoneDirection(StringView bone, bool worldSpace = false) const;[client] Bones: first-person local (or world) space, third-person world space.
Parameters
bone(StringView): The joint name.worldSpace(bool): Whether to convert the position to world space. (Defaults to true)
Returns Vec3
Lua: Tool:getFpBoneDir
Quat fpBoneRotation(StringView bone, bool worldSpace = false) const;[client] Bones: first-person local (or world) space, third-person world space.
Parameters
bone(StringView): The joint name.worldSpace(bool): Whether to convert the position to world space. (Defaults to true)
Returns Quat
Lua: Tool:getFpBoneRot
Vec3 tpBoneDirection(StringView bone) const;[client] Bones: first-person local (or world) space, third-person world space.
Parameters
bone(StringView): The joint name.
Returns Vec3
Lua: Tool:getTpBoneDir
Quat tpBoneRotation(StringView bone) const;[client] Bones: first-person local (or world) space, third-person world space.
Parameters
bone(StringView): The joint name.
Returns Quat
Lua: Tool:getTpBoneRot
void updateJoint(StringView bone, Vec3 rotation, Optional<double> weight = atl::none) const;[client] Rotates a bone of the animation skeleton.
Parameters
bone(StringView)rotation(Vec3)weight(Optional<double>)
Lua: Tool:updateJoint
AnimationInfo animationInfo(StringView name) const;[client] Information about a third person animation.
Parameters
name(StringView)
Returns AnimationInfo
Lua: Tool:getAnimationInfo
AnimationInfo fpAnimationInfo(StringView name) const;[client] Information about a first person animation.
Parameters
name(StringView): The name.
Returns AnimationInfo
Lua: Tool:getFpAnimationInfo
void updateMovementAnimation(double time, Optional<double> weight = atl::none) const;[client] Advances the movement animation set with setMovementAnimation.
Parameters
time(double)weight(Optional<double>)
Lua: Tool:updateMovementAnimation
Vec3 relativeMoveDirection() const;[client] Movement direction relative to where the player looks.
Returns Vec3
Lua: Tool:getRelativeMoveDirection
void updateFpCamera(double fov, Vec3 offset, double weight, double bobbing) const;[client] Blends the first person camera toward a tool-specific view.
Parameters
fov(double)offset(Vec3)weight(double)bobbing(double)
Lua: Tool:updateFpCamera
CameraWeights cameraWeights() const;[client] Current weights of the tool's camera settings (updateCamera / updateFpCamera).
Returns CameraWeights
CameraWeights
Section titled "CameraWeights"Weights of the third / first person camera settings.
struct CameraWeightsdouble thirdPerson = 0, firstPerson = 0;LoadCellHandle
Section titled "LoadCellHandle"The handle from World::loadCellWithHandle; the cell stays loaded until released.
class LoadCellHandle : public atl::Objectbool release() const;[server] Releases the cell; returns true if it was held.
Returns bool
Lua: LoadCellHandle:release
A player's or non-player lift (Lua Lift).
class Lift : public atl::Objectint id() const;The lift's id.
Returns int
Lua: Lift:getId
int level() const;Its height level.
Returns int
Lua: Lift:getLevel
Vec3 worldPosition() const;Its position.
Returns Vec3
Lua: Lift:getWorldPosition
bool hasBodies() const;True if it carries bodies.
Returns bool
Lua: Lift:hasBodies
void destroy() const;[server] Removes the lift.
Lua: Lift:destroy
Portal
Section titled "Portal"A two-opening portal between (or within) worlds. All [server].
class Portal : public atl::Objectint id() const;The portal's id.
Returns int
Lua: Portal:getId
bool hasOpeningA() const;[server] True if opening A / B is placed.
Returns bool
Lua: Portal:hasOpeningA
bool hasOpeningB() const;[server] True if opening A / B is placed.
Returns bool
Lua: Portal:hasOpeningB
void setOpeningA(Vec3 position, Quat rotation, const World &world = {}) const;[server] Places opening A / B.
Parameters
position(Vec3): The portal opening A position.rotation(Quat): The portal opening A rotation.world(const World &): The world to look in (Optional, defaults to world from script context)
Lua: Portal:setOpeningA
void setOpeningB(Vec3 position, Quat rotation, const World &world = {}) const;[server] Places opening A / B.
Parameters
position(Vec3): The portal opening B position.rotation(Quat): The portal opening B rotation.world(const World &): The world to look in (Optional, defaults to world from script context)
Lua: Portal:setOpeningB
Vec3 positionA() const;[server] Positions, rotations and worlds of the two openings.
Returns Vec3
Lua: Portal:getPositionA
Vec3 positionB() const;[server] Positions, rotations and worlds of the two openings.
Returns Vec3
Lua: Portal:getPositionB
Quat rotationA() const;[server] Positions, rotations and worlds of the two openings.
Returns Quat
Lua: Portal:getRotationA
Quat rotationB() const;[server] Positions, rotations and worlds of the two openings.
Returns Quat
Lua: Portal:getRotationB
World worldA() const;[server] Positions, rotations and worlds of the two openings.
Returns World
Lua: Portal:getWorldA
World worldB() const;[server] Positions, rotations and worlds of the two openings.
Returns World
Lua: Portal:getWorldB
Vector<Target> contentsA() const;[server] Characters and bodies in each opening.
Returns Vector<Target>
Vector<Target> contentsB() const;[server] Characters and bodies in each opening.
Returns Vector<Target>
bool transferAToB(Optional<int> filter = atl::none) const;[server] Moves what's in one opening to the other (filter: sm.areaTrigger.filter).
Parameters
filter(Optional<int>): Asm.physics.filtermask selecting which contents to transfer. Only [sm.physics.filter, dynamicBody], [sm.physics.filter, staticBody] and [sm.physics.filter, character] are meaningful. Defaults to transferring bodies and characters. (Optional)
Returns bool
Lua: Portal:transferAToB
bool transferBToA(Optional<int> filter = atl::none) const;[server] Moves what's in one opening to the other (filter: sm.areaTrigger.filter).
Parameters
filter(Optional<int>): Asm.physics.filtermask selecting which contents to transfer. Only [sm.physics.filter, dynamicBody], [sm.physics.filter, staticBody] and [sm.physics.filter, character] are meaningful. Defaults to transferring bodies and characters. (Optional)
Returns bool
Lua: Portal:transferBToA
void setAMarkerOffset(Vec3 offset) const;[server] Map markers: offsets, and whether each direction shows one.
Parameters
offset(Vec3): The offset of the world marker in world space.
Lua: Portal:setAMarkerOffset
void setBMarkerOffset(Vec3 offset) const;[server] Map markers: offsets, and whether each direction shows one.
Parameters
offset(Vec3): The offset of the world marker in world space.
Lua: Portal:setBMarkerOffset
void setAToBMarkerAllowed(bool allowed) const;[server] Map markers: offsets, and whether each direction shows one.
Parameters
allowed(bool): Whether the portal is allowed to show A to B connection
Lua: Portal:setAToBMarkerAllowed
void setBToAMarkerAllowed(bool allowed) const;[server] Map markers: offsets, and whether each direction shows one.
Parameters
allowed(bool): Whether the portal is allowed to show A to B connection
Lua: Portal:setBToAMarkerAllowed
Storage
Section titled "Storage"Server-side save data of a script (ScriptClass::storage()). All [server].
class Storage : public atl::ObjectValue load() const;[server] The saved data, or nil.
Returns Value
Lua: Storage:load
template <class T> void save(const T &data) const;[server] Saves data for the next time the object loads.
Parameters
data(const T &): The data to be stored.
Lua: Storage:save
Target
Section titled "Target"A value that may be one of several object types (a collision's "other", a projectile's shooter, ...). Test with is<T>(), convert with as<T>().
class Target : public atl::ObjectString kind() const;Lua's type(): "Shape", "Character", "Player", "Harvestable", "Unit", ...
Returns String
template <class T> bool is() const;True if the value is a T.
Returns bool
template <class T> T as() const;The value as a T.
Returns T
The AI driving a creature (Lua Unit). Most calls are [server].
class Unit : public atl::Objectint id() const;[server] The unit's id.
Returns int
Lua: Unit:getId
Character character() const;[server] The character it controls.
Returns Character
Lua: Unit:getCharacter
Vec3 facingDirection() const;[server] The current facing / movement direction.
Returns Vec3
Lua: Unit:getCurrentFacingDirection
Vec3 movementDirection() const;[server] The current facing / movement direction.
Returns Vec3
Lua: Unit:getCurrentMovementDirection
void setFacingDirection(Vec3 d) const;[server] Sets the direction to face / move in.
Parameters
d(Vec3): The desired facing direction.
Lua: Unit:setFacingDirection
void setMovementDirection(Vec3 d) const;[server] Sets the direction to face / move in.
Parameters
d(Vec3): The desired movement direction.
Lua: Unit:setMovementDirection
void setMovementType(StringView type) const;[server] Sets how to move: "stand", "walk", "sprint", "crouch", ...
Parameters
type(StringView): The movement type to set
Lua: Unit:setMovementType
void setWantsJump(bool jump) const;[server] Requests a jump / crouch.
Parameters
jump(bool): True if the unit should jump
Lua: Unit:setWantsJump
void setWantsCrouch(bool crouch) const;[server] Requests a jump / crouch.
Parameters
crouch(bool): True if the unit should crouch
Lua: Unit:setWantsCrouch
void setWhiskerData(int count, double maxAngle, double startLength, double endLength) const;[server] Configures the obstacle-sensing rays used for movement.
Parameters
count(int): The whiskerCount.maxAngle(double): The maxAngle.startLength(double): The startLength.endLength(double): The endLength.
Lua: Unit:setWhiskerData
void setHearingData(double noiseScale) const;[server] Scales how well the unit hears noise.
Parameters
noiseScale(double): The noise amount.
Lua: Unit:setHearingData
void sendCharacterEvent(StringView event) const;[server] Fires client_onEvent on the unit's character.
Parameters
event(StringView): The event name.
Lua: Unit:sendCharacterEvent
Value publicData() const;[server] Data other scripts can read, and setting it.
Returns Value
Lua: Unit:getPublicData
void setPublicData(const Value &t) const;[server] Data other scripts can read, and setting it.
Parameters
t(const Value &): The public data.
Lua: Unit:setPublicData
Container container(int index = 0) const;A container of the unit by index.
Parameters
index(int): The index of the container (default: 0).
Returns Container
Lua: Unit:getContainer
Container addContainer(int index, int size, Optional<int> stackSize = atl::none) const;[server] Adds a container of size slots.
Parameters
index(int): The index of the container [0-15].size(int): The number of slots in the container.stackSize(Optional<int>): The stack size. Defaults to maximum possible stack size(65535).
Returns Container
Lua: Unit:addContainer
void removeContainer(int index) const;[server] Removes a container.
Parameters
index(int): The index of the container.
Lua: Unit:removeContainer
AiState createState(StringView name) const;[server] Creates a built-in AI behaviour by name (see AiState).
Parameters
name(StringView): Name of predefined ai state.
Returns AiState
Lua: Unit:createState
void destroy() const;[server] Destroys the unit.
Lua: Unit:destroy
AiState
Section titled "AiState"A built-in AI behaviour from Unit::createState. Drive it from server_onUnitUpdate. All [server].
class AiState : public atl::Objectvoid start() const;[server] Starts / stops the behaviour.
Lua: AiState:start
void stop() const;[server] Starts / stops the behaviour.
Lua: AiState:stop
void onFixedUpdate(double dt) const;[server] Advances the behaviour; call from the matching unit callback.
Parameters
dt(double): The delta time.
Lua: AiState:onFixedUpdate
void onUnitUpdate(double dt) const;[server] Advances the behaviour; call from the matching unit callback.
Parameters
dt(double): The delta time.
Lua: AiState:onUnitUpdate
Done isDone() const;[server] Whether it's done, and why (e.g. "finished" / "failed").
Returns Done
Vec3 facingDirection() const;[server] What the state wants the unit to do; apply it with the Unit setters.
Returns Vec3
Lua: AiState:getFacingDirection
Vec3 movementDirection() const;[server] What the state wants the unit to do; apply it with the Unit setters.
Returns Vec3
Lua: AiState:getMovementDirection
String movementType() const;[server] What the state wants the unit to do; apply it with the Unit setters.
Returns String
Lua: AiState:getMovementType
bool wantsJump() const;[server] What the state wants the unit to do; apply it with the Unit setters.
Returns bool
Lua: AiState:getWantsJump
bool wantsCrouch() const;[server] What the state wants the unit to do; apply it with the Unit setters.
Returns bool
Lua: AiState:getWantsCrouch
Whether the behaviour has finished, and why.
struct Donebool done = false;String reason;explicit operator bool() const;PathNode
Section titled "PathNode"A navigation node for sm.pathfinder (pathNodes::create). All [server].
class PathNode : public atl::ObjectVec3 position() const;[server] The node's position.
Returns Vec3
Lua: PathNode:getPosition
void connect(const PathNode &to) const;[server] Links this node to another.
Parameters
to(const PathNode &): PathNode to create connection to
Lua: PathNode:connect
void destroy() const;[server] Removes the node.
Lua: PathNode:destroy
ScriptableObject
Section titled "ScriptableObject"A scriptable object: a script with no body in the world (Lua ScriptableObject).
class ScriptableObject : public atl::Objectint id() const;The object's id.
Returns int
Lua: ScriptableObject:getId
World world() const;The world it's in.
Returns World
Lua: ScriptableObject:getWorld
Value data() const;The params it was created with.
Returns Value
Lua: ScriptableObject:getData
Value publicData() const;[server] Data other server scripts can read.
Returns Value
Lua: ScriptableObject:getPublicData
void setPublicData(const Value &t) const;[server] Sets data other server scripts can read.
Parameters
t(const Value &): The public data.
Lua: ScriptableObject:setPublicData
Value clientPublicData() const;[client] Data other client scripts can read.
Returns Value
Lua: ScriptableObject:getClientPublicData
void setClientPublicData(const Value &t) const;[client] Sets data other client scripts can read.
Parameters
t(const Value &): The client public data.
Lua: ScriptableObject:setClientPublicData
void destroy() const;[server] Destroys the object.
Lua: ScriptableObject:destroy
ClientScriptableObject
Section titled "ClientScriptableObject"A scriptable object that only exists on one client (clientScriptableObjects::create). All [client].
class ClientScriptableObject : public atl::Objectint id() const;The object's id.
Returns int
Lua: ClientScriptableObject:getId
World world() const;The world it's in.
Returns World
Lua: ClientScriptableObject:getWorld
Value data() const;The params it was created with.
Returns Value
Lua: ClientScriptableObject:getData
Value clientPublicData() const;Data other client scripts can read, and setting it.
Returns Value
Lua: ClientScriptableObject:getClientPublicData
void setClientPublicData(const Value &t) const;Data other client scripts can read, and setting it.
Parameters
t(const Value &): The client public data.
Lua: ClientScriptableObject:setClientPublicData
void destroy() const;Destroys the object.
Lua: ClientScriptableObject:destroy
ProjectileHit
Section titled "ProjectileHit"A projectile hit, as passed to *_onProjectile callbacks.
struct ProjectileHitVec3 position;double airTime = 0;Vec3 velocity;String projectile;Target shooter;int damage = 0;Value customData;Vec3 normal;Uuid uuid;double mass = 0;static ProjectileHit fromArgs(const Value &a, int i);Builds the struct from callback arguments starting at index i.
Parameters
a(const Value &)i(int)
Returns ProjectileHit
MeleeHit
Section titled "MeleeHit"A melee hit, as passed to *_onMelee callbacks.
struct MeleeHitVec3 position;Target attacker;int damage = 0;double power = 0;Vec3 direction;Vec3 normal;static MeleeHit fromArgs(const Value &a, int i);Builds the struct from callback arguments starting at index i.
Parameters
a(const Value &)i(int)
Returns MeleeHit
CollisionHit
Section titled "CollisionHit"A collision, as passed to *_onCollision callbacks.
struct CollisionHitTarget other;Vec3 position;Vec3 selfPointVelocity;Vec3 otherPointVelocity;Vec3 normal;static CollisionHit fromArgs(const Value &a, int i);Builds the struct from callback arguments starting at index i.
Parameters
a(const Value &)i(int)
Returns CollisionHit
WorldProjectileHit
Section titled "WorldProjectileHit"A projectile hit as passed to WorldClass callbacks, with the object that was hit.
struct WorldProjectileHit : ProjectileHitTarget target;static WorldProjectileHit fromArgs(const Value &a, int i);Builds the struct from callback arguments starting at index i (server calls carry customData).
Parameters
a(const Value &)i(int)
Returns WorldProjectileHit
WorldMeleeHit
Section titled "WorldMeleeHit"A melee hit as passed to WorldClass callbacks, with the object that was hit.
struct WorldMeleeHit : MeleeHitTarget target;static WorldMeleeHit fromArgs(const Value &a, int i);Builds the struct from callback arguments starting at index i.
Parameters
a(const Value &)i(int)
Returns WorldMeleeHit
WorldCollision
Section titled "WorldCollision"A collision between two objects, as passed to WorldClass callbacks.
struct WorldCollisionTarget a, b;Vec3 position;Vec3 pointVelocityA, pointVelocityB;Vec3 normal;static WorldCollision fromArgs(const Value &v, int i);Builds the struct from callback arguments starting at index i.
Parameters
v(const Value &)i(int)
Returns WorldCollision
sm::log
Section titled "sm::log"Writing to the game log. fmt uses "{}" placeholders, as atl::format.
template <class... A> void info(StringView fmt, const A &...args);Logs an info line.
Parameters
fmt(StringView)args(const A &...)
Lua: sm.log.info
template <class... A> void warn(StringView fmt, const A &...args);Logs a warning.
Parameters
fmt(StringView)args(const A &...)
Lua: sm.log.warning
template <class... A> void error(StringView fmt, const A &...args);Logs an error.
Parameters
fmt(StringView)args(const char *const &)args(const char *const &)args(const char &[7])args(const char *const &)args(const char &[7])
Lua: sm.log.error
sm::game
Section titled "sm::game"Game state and settings (sm.game).
inline int serverTick();The server's tick counter.
Returns int
Lua: sm.game.getServerTick
inline int currentTick();The current tick (40 per second).
Returns int
Lua: sm.game.getCurrentTick
inline double timeOfDay();The time of day, 0..1, where 0.5 is noon.
Returns double
Lua: sm.game.getTimeOfDay
inline void setTimeOfDay(double t);[client] Sets the time of day.
Parameters
t(double): The fraction of the day cycle.
Lua: sm.game.setTimeOfDay
inline int difficulty();The game difficulty.
Returns int
Lua: sm.game.getDifficulty
inline bool aggroEnabled();Whether creature aggression is enabled.
Returns bool
Lua: sm.game.getEnableAggro
inline void setAggroEnabled(bool on);[server] Enables or disables creature aggression.
Parameters
on(bool): The enable state.
Lua: sm.game.setEnableAggro
inline bool ammoConsumptionEnabled();Whether ammo consumption is enabled.
Returns bool
Lua: sm.game.getEnableAmmoConsumption
inline void setAmmoConsumptionEnabled(bool on);[server] Enables or disables ammo consumption.
Parameters
on(bool): The enable state.
Lua: sm.game.setEnableAmmoConsumption
inline bool fuelConsumptionEnabled();Whether fuel consumption is enabled.
Returns bool
Lua: sm.game.getEnableFuelConsumption
inline void setFuelConsumptionEnabled(bool on);[server] Enables or disables fuel consumption.
Parameters
on(bool): The enable state.
Lua: sm.game.setEnableFuelConsumption
inline bool restrictionsEnabled();Whether build restrictions are enabled.
Returns bool
Lua: sm.game.getEnableRestrictions
inline void setRestrictionsEnabled(bool on);[server] Enables or disables build restrictions.
Parameters
on(bool): Restrictions enable state.
Lua: sm.game.setEnableRestrictions
inline bool upgradeEnabled();Whether upgrades are enabled.
Returns bool
Lua: sm.game.getEnableUpgrade
inline void setUpgradeEnabled(bool on);[server] Enables or disables upgrades.
Parameters
on(bool): The enable state.
Lua: sm.game.setEnableUpgrade
inline bool recipesEnabled();Whether recipes are enabled.
Returns bool
Lua: sm.game.getRecipesEnabled
inline void setRecipesEnabled(bool on);[server] Enables or disables recipes.
Parameters
on(bool): The enable state.
Lua: sm.game.setEnableRecipes
inline bool limitedInventory();Whether the limited inventory is enabled.
Returns bool
Lua: sm.game.getLimitedInventory
inline void setLimitedInventory(bool on);[server] Enables or disables the limited inventory.
Parameters
on(bool): Is limited.
Lua: sm.game.setLimitedInventory
inline bool settingBool(StringView name);A game setting by name, as a boolean / number / string.
Parameters
name(StringView): The name of the setting
Returns bool
Lua: sm.game.getSettingBoolean
inline double settingNumber(StringView name);A game setting by name, as a boolean / number / string.
Parameters
name(StringView): The name of the setting
Returns double
Lua: sm.game.getSettingValue
inline String settingString(StringView name);A game setting by name, as a boolean / number / string.
Parameters
name(StringView): The name of the setting
Returns String
Lua: sm.game.getSettingString
inline void kick(const Player &p);[server] Kicks a player.
Parameters
p(const Player &): The player to be kicked.
Lua: sm.game.kickPlayer
inline void ban(const Player &p);[server] Bans a player.
Parameters
p(const Player &): The player to be banned.
Lua: sm.game.banPlayer
inline void pauseSaving(StringView reason, int ticks);[server] Holds off autosaving while something (named reason) is mid-change.
Parameters
reason(StringView): The name identifying this pause request.ticks(int): The number of ticks to pause saving for.
Lua: sm.game.pauseSaving
inline void resumeSaving(StringView reason);[server] Allows autosaving again.
Parameters
reason(StringView): The name identifying the pause request to remove.
Lua: sm.game.resumeSaving
inline void exitToMenu();Exits to the main menu.
Lua: sm.game.exitToMenu
inline void exitToMenuWithEndCredits();Exits to the main menu and plays the end credits.
Lua: sm.game.exitToMenuWithEndCredits
inline Value loadWatchedTutorials();[client] The tutorials the user has seen (a table you define).
Returns Value
Lua: sm.game.loadWatchedTutorials
inline void saveWatchedTutorials(const Value &watched);[client] Saves the tutorials the user has seen.
Parameters
watched(const Value &): The table of watched tutorials.
Lua: sm.game.saveWatchedTutorials
sm::gui
Section titled "sm::gui"inline void chat(StringView message);Posts a chat message.
Parameters
message(StringView): The message.
Lua: sm.gui.chatMessage
inline void alert(StringView text, double seconds = 4, bool queued = false);Shows centered alert text for seconds, optionally after any queued alerts.
Parameters
text(StringView): The message to be displayedseconds(double): The time in seconds during which the message is shown. Defaults to 4 secondsqueued(bool): If true the message is queued, otherwise it is displayed instantly. Defaults to false
Lua: sm.gui.displayAlertText
inline String keyBinding(StringView action, bool colored = true);The key bound to an input action (e.g. "Use"), formatted for interaction text.
Parameters
action(StringView): The actioncolored(bool): If the string should contain hyper text (Defaults to false)
Returns String
Lua: sm.gui.getKeyBinding
inline void interaction(StringView action, StringView label);Sets the interaction text: "[key] label", e.g. gui::interaction("Use", "Toggle").
Parameters
action(StringView)label(StringView)
Lua: sm.gui.setInteractionText
inline void setInteractionText(StringView text1, StringView binding1 = {}, StringView text2 = {}, StringView binding2 = {}, StringView text3 = {});Sets the interaction text from raw parts (sm.gui.setInteractionText).
Parameters
text1(StringView): The leftmost segment.binding1(StringView): The left white segment.text2(StringView): The mid or end segment.binding2(StringView): The right white segment.text3(StringView): The rightmost segment.
Lua: sm.gui.setInteractionText
sm::audio
Section titled "sm::audio"Sounds (sm.audio).
inline void play(StringView sound, Optional<Vec3> position = atl::none);Plays a sound, at a position or globally.
Parameters
sound(StringView)position(Optional<Vec3>)
Lua: sm.audio.play
inline double globalParameter(StringView name);[client] Reads / writes an FMOD global parameter.
Parameters
name(StringView): The name.
Returns double
Lua: sm.audio.getGlobalParameter
inline void setGlobalParameter(StringView name, double value);[client] Reads / writes an FMOD global parameter.
Parameters
name(StringView): The name.value(double): The parameter value.
Lua: sm.audio.setGlobalParameter
sm::effect
Section titled "sm::effect"Effects (sm.effect).
inline void play(StringView name, Vec3 position, const PlayOptions &o = {});Plays a one-shot effect at a position.
Parameters
name(StringView)position(Vec3)o(const PlayOptions &)
Lua: sm.effect.playEffect
inline Effect create(StringView name);Creates an effect you control (see Effect).
Parameters
name(StringView)
Returns Effect
Lua: sm.effect.createEffect
template <class Host> Effect createOn(StringView name, const Host &host, StringView bone = {});Creates an effect attached to a host, optionally to a bone.
Parameters
name(StringView)host(const Host &)bone(StringView)
Returns Effect
Lua: sm.effect.createEffect
inline Effect create2D(StringView name);[client] Creates a screen-space, first-person or sky effect.
Parameters
name(StringView)
Returns Effect
Lua: sm.effect.createEffect2D
inline Effect createFirstPerson(StringView name);[client] Creates a screen-space, first-person or sky effect.
Parameters
name(StringView): The name of the effect.
Returns Effect
Lua: sm.effect.createEffectFirstPerson
inline Effect createSky(StringView name);[client] Creates a screen-space, first-person or sky effect.
Parameters
name(StringView): The name of the effect.
Returns Effect
Lua: sm.effect.createEffectSky
inline double estimateSize(StringView name, const Value ¶meters = Value::table());[client] The radius of influence of name with these parameters.
Parameters
name(StringView)parameters(const Value &)
Returns double
Lua: sm.effect.estimateSize
template <class Host> void playHosted(StringView name, const Host &host, const HostedOptions &o = {});[client] A fire-and-forget effect that follows host (Shape, Interactable, Character or Harvestable).
Parameters
name(StringView)host(const Host &)o(const HostedOptions &)
Lua: sm.effect.playHostedEffect
PlayOptions
Section titled "PlayOptions"Options for effect::play.
struct PlayOptionsOptional<Vec3> velocity;Optional<Quat> rotation;Optional<Vec3> scale;Value parameters;HostedOptions
Section titled "HostedOptions"Options for effect::playHosted.
struct HostedOptionsStringView bone;Value parameters;Optional<int> axis;Optional<double> startTime;Optional<Vec3> offsetPosition;Optional<Quat> offsetRotation;Optional<Vec3> scale;sm::physics
Section titled "sm::physics"Physics queries and forces (sm.physics).
inline Optional<RaycastHit> toHit(const Vector<Value> &r);Converts the engine's (hit, result) pair to a RaycastHit; none on a miss.
Parameters
r(const Vector<Value> &)
Returns Optional<RaycastHit>
inline Optional<RaycastHit> raycast(Vec3 from, Vec3 to, const RaycastOptions &o = {});Casts a ray from from to to; none on a miss.
Parameters
from(Vec3)to(Vec3)o(const RaycastOptions &)
Returns Optional<RaycastHit>
Lua: sm.physics.raycast
inline Optional<RaycastHit> raycastTarget(Vec3 from, Vec3 to, const Body &target);Casts a ray that only hits target.
Parameters
from(Vec3)to(Vec3)target(const Body &)
Returns Optional<RaycastHit>
Lua: sm.physics.raycastTarget
inline Optional<RaycastHit> spherecast(Vec3 from, Vec3 to, double radius, const RaycastOptions &o = {});Casts a sphere / capsule along a line.
Parameters
from(Vec3)to(Vec3)radius(double)o(const RaycastOptions &)
Returns Optional<RaycastHit>
Lua: sm.physics.spherecast
inline Optional<RaycastHit> capsulecast(Vec3 from, Vec3 to, double radius, double height, const RaycastOptions &o = {});Casts a sphere / capsule along a line.
Parameters
from(Vec3)to(Vec3)radius(double)height(double)o(const RaycastOptions &)
Returns Optional<RaycastHit>
Lua: sm.physics.capsulecast
inline Contacts toContacts(const Value &t);Reads a contacts table.
Parameters
t(const Value &)
Returns Contacts
inline Contacts sphereContacts(Vec3 center, double radius, Optional<int> mask = atl::none);Everything overlapping a sphere / box.
Parameters
center(Vec3)radius(double)mask(Optional<int>)
Returns Contacts
Lua: sm.physics.getSphereContacts
inline Contacts boxContacts(Vec3 center, Quat rotation, Vec3 halfExtents, const World &world, Optional<int> mask = atl::none);Everything overlapping a sphere / box.
Parameters
center(Vec3): The world position of the box center.rotation(Quat): The rotation of the box.halfExtents(Vec3): The half extents of the box.world(const World &): The world to search in. (optional)mask(Optional<int>): The collision mask. Defaults to [sm.physics.filter, sm.physics.filter.static] and [sm.physics.filter, sm.physics.filter.dynamicBody] and [sm.physics.filter, sm.physics.filter.character] (Optional)
Returns Contacts
Lua: sm.physics.getBoxContacts
inline Vector<Shape> shapesInSphere(Vec3 center, double radius, const World &world);Shapes overlapping a sphere / box.
Parameters
center(Vec3): The center position of the sphere.radius(double): The radius of the sphere.world(const World &): The world to search in. (optional)
Returns Vector<Shape>
Lua: sm.physics.getShapeContactsInSphere
inline Vector<Shape> shapesInBox(Vec3 center, Quat rotation, Vec3 halfExtents, const World &world);Shapes overlapping a sphere / box.
Parameters
center(Vec3): The center position of the box.rotation(Quat): The rotation of the box.halfExtents(Vec3): The halved size of the box.world(const World &): The world to search in. (optional)
Returns Vector<Shape>
Lua: sm.physics.getShapeContactsInBox
inline bool sphereHasContact(Vec3 center, double radius, bool includeTerrain = true, bool countWater = false);Whether anything overlaps a sphere, and how many things.
Parameters
center(Vec3)radius(double)includeTerrain(bool)countWater(bool)
Returns bool
Lua: sm.physics.sphereHasContact
inline int sphereContactCount(Vec3 center, double radius, bool includeTerrain = true, bool countWater = false);Whether anything overlaps a sphere, and how many things.
Parameters
center(Vec3)radius(double)includeTerrain(bool)countWater(bool)
Returns int
Lua: sm.physics.sphereContactCount
inline bool capsuleHasContact(Vec3 from, Vec3 to, double radius, Optional<int> mask = atl::none);Whether anything overlaps a capsule, and how many things.
Parameters
from(Vec3): The world position of the first sphere.to(Vec3): The world position of the second sphere.radius(double): The radius of the spheres.mask(Optional<int>): The collision mask. Defaults to [sm.physics.filter, sm.physics.filter.default] (Optional)
Returns bool
Lua: sm.physics.capsuleHasContact
inline int capsuleContactCount(Vec3 from, Vec3 to, double radius, Optional<int> mask = atl::none);Whether anything overlaps a capsule, and how many things.
Parameters
from(Vec3): The world position of the first sphere.to(Vec3): The world position of the second sphere.radius(double): The radius of the spheres.mask(Optional<int>): The collision mask. Defaults to [sm.physics.filter, sm.physics.filter.default] (Optional)
Returns int
Lua: sm.physics.capsuleContactCount
inline Optional<double> distanceRaycast(Vec3 start, Vec3 direction);A cheap ray: just the fraction (0..1) of direction travelled before a hit.
Parameters
start(Vec3): The start position.direction(Vec3): The ray's direction and length.
Returns Optional<double>
Lua: sm.physics.distanceRaycast
inline Vector<Optional<RaycastHit>> multicast(const Vector<Cast> &casts, const World &world = {});Runs every cast in one engine call; results are in the same order.
Parameters
casts(const Vector<Cast> &)world(const World &): The world to perform the cast in. (Optional)
Returns Vector<Optional<RaycastHit>>
Lua: sm.physics.multicast
inline bool isPointInLiquid(Vec3 point);True if the point / sphere is in liquid.
Parameters
point(Vec3)
Returns bool
Lua: sm.physics.isPointInLiquid
inline bool isSphereInLiquid(Vec3 center, double radius);True if the point / sphere is in liquid.
Parameters
center(Vec3)radius(double)
Returns bool
Lua: sm.physics.isSphereHittingLiquid
inline String groundMaterial(Vec3 point);The ground material at a point.
Parameters
point(Vec3): The world position to check the material at.
Returns String
Lua: sm.physics.getGroundMaterial
inline int materialId(StringView material);A physics material's id by name.
Parameters
material(StringView): Material name.
Returns int
Lua: sm.physics.getMaterialId
inline int filter(StringView name);A raycast filter value by name (sm.physics.filter[name]).
Parameters
name(StringView)
Returns int
Lua: sm.physics.filter
inline double gravity();[server] The gravity strength.
Returns double
Lua: sm.physics.getGravity
inline void setGravity(double g);[server] Sets the gravity strength.
Parameters
g(double): The gravitational value.
Lua: sm.physics.setGravity
inline void explode(Vec3 position, const ExplosionOptions &o = {});[server] Creates an explosion.
Parameters
position(Vec3)o(const ExplosionOptions &)
Lua: sm.physics.explode
RaycastHit
Section titled "RaycastHit"What a raycast hit. type is "body", "character", "terrainSurface", "areaTrigger", ...
point/normal are in world space; pointLocal/normalLocal relative to what was hit.
struct RaycastHitString type;Vec3 point;Vec3 normal;Vec3 pointLocal;Vec3 normalLocal;Vec3 origin;Vec3 direction;double fraction = 0;Value raw;bool is(StringView t) const;True if the hit type is t.
Parameters
t(StringView)
Returns bool
Shape shape() const;The object that was hit, when the type matches.
Returns Shape
Body body() const;The object that was hit, when the type matches.
Returns Body
Character character() const;The object that was hit, when the type matches.
Returns Character
Harvestable harvestable() const;The object that was hit, when the type matches.
Returns Harvestable
Joint joint() const;The object that was hit, when the type matches.
Returns Joint
AreaTrigger areaTrigger() const;The object that was hit, when the type matches.
Returns AreaTrigger
LiftHit lift() const;Reads a lift hit.
Returns LiftHit
String terrainAssetMaterial() const;The material name of a hit terrain asset.
Returns String
LiftHit
Section titled "LiftHit"A lift hit, and whether its top was hit.
struct LiftHitLift lift;bool isTop = false;RaycastOptions
Section titled "RaycastOptions"Optional raycast settings: a body to ignore and an sm.physics.filter mask.
struct RaycastOptionsBody ignore;Optional<int> mask;Contacts
Section titled "Contacts"What overlaps a volume.
struct ContactsVector<Body> bodies;Vector<Character> characters;Vector<Harvestable> harvestables;Value raw;One cast of a multicast batch.
struct Castenum Kind { Ray, Sphere } kind = Ray;Vec3 from, to;double radius = 0;Optional<int> mask;Vector<Uuid> ignoreUuids;static Cast ray(Vec3 from, Vec3 to, Optional<int> mask = atl::none);A ray / sphere cast.
Parameters
from(Vec3)to(Vec3)mask(Optional<int>)
Returns Cast
static Cast sphere(Vec3 from, Vec3 to, double radius, Optional<int> mask = atl::none);A ray / sphere cast.
Parameters
from(Vec3)to(Vec3)radius(double)mask(Optional<int>)
Returns Cast
enum Kind { Ray, Sphere };ExplosionOptions
Section titled "ExplosionOptions"Explosion settings.
struct ExplosionOptionsint level = 5;double destructionRadius = 0.5;double impulseRadius = 2;double magnitude = 20;Optional<String> effect;sm::players
Section titled "sm::players"Players (sm.player).
inline Vector<Player> all();Every connected player.
Returns Vector<Player>
Lua: sm.player.getAllPlayers
inline Player host();The host player.
Returns Player
Lua: sm.player.getHostPlayer
inline Player local();[client] This client's player.
Returns Player
Lua: sm.localPlayer.getPlayer
inline void placeLift(const Player &p, const Vector<Body> &creation, Vec3 position, int level, int rotation);[server] Same as Player::placeLift / removeLift.
Parameters
p(const Player &): The player that owns the lift.creation(const Vector<Body> &)position(Vec3): The lift position.level(int): The lift level.rotation(int): The rotation of the creation on the lift.
Lua: sm.player.placeLift
inline void removeLift(const Player &p);[server] Same as Player::placeLift / removeLift.
Parameters
p(const Player &): The player that owns the lift.
Lua: sm.player.removeLift
sm::shapes
Section titled "sm::shapes"Creating and inspecting shapes (sm.shape).
inline Shape createPart(const Uuid &uuid, Vec3 position, Quat rotation = {}, bool dynamic = true);[server] Creates a part.
Parameters
uuid(const Uuid &)position(Vec3)rotation(Quat)dynamic(bool)
Returns Shape
Lua: sm.shape.createPart
inline Shape createBlock(const Uuid &uuid, Vec3 size, Vec3 position, Quat rotation = {}, bool dynamic = true);[server] Creates a block of size.
Parameters
uuid(const Uuid &)size(Vec3)position(Vec3)rotation(Quat)dynamic(bool)
Returns Shape
Lua: sm.shape.createBlock
inline Shape createWedge(const Uuid &uuid, Vec3 size, Vec3 position, Quat rotation = {}, bool dynamic = true, bool forceSpawn = false);[server] Creates a wedge of size with its corner at position.
Parameters
uuid(const Uuid &)size(Vec3)position(Vec3)rotation(Quat)dynamic(bool)forceSpawn(bool)
Returns Shape
Lua: sm.shape.createWedge
inline String title(const Uuid &uuid);An item's display name / upper-case display name.
Parameters
uuid(const Uuid &): The uuid.
Returns String
Lua: sm.shape.getShapeTitle
inline String upperCaseTitle(const Uuid &uuid);An item's display name / upper-case display name.
Parameters
uuid(const Uuid &): The uuid.
Returns String
Lua: sm.shape.getShapeUpperCaseTitle
inline Color typeColor(const Uuid &uuid);The color of the shape's type (block, part, ...) in the inventory.
Parameters
uuid(const Uuid &): The uuid of the shape.
Returns Color
Lua: sm.shape.getShapeTypeColor
inline bool isHarvest(const Uuid &uuid);True for a harvested item / a stackable item.
Parameters
uuid(const Uuid &): The shape uuid.
Returns bool
Lua: sm.shape.getIsHarvest
inline bool isStackable(const Uuid &uuid);True for a harvested item / a stackable item.
Parameters
uuid(const Uuid &): The shape uuid.
Returns bool
Lua: sm.shape.getIsStackable
inline bool exists(const Uuid &uuid);True if a shape with this uuid exists.
Parameters
uuid(const Uuid &): The shape uuid.
Returns bool
Lua: sm.shape.uuidExists
inline Vector<Shape> inSphere(Vec3 center, double radius);Shapes within a sphere.
Parameters
center(Vec3): The center position of the sphere.radius(double): The radius of the sphere.
Returns Vector<Shape>
Lua: sm.shape.shapesInSphere
sm::bodies
Section titled "sm::bodies"Bodies (sm.body).
inline Body create(Vec3 position, Quat rotation = {}, bool dynamic = false);[server] Creates an empty body to build on (Body::createBlock / createPart).
Parameters
position(Vec3): The body's world position.rotation(Quat): The body's world rotation. (Defaults tosm.quat.identity)dynamic(bool): Set true if the body is dynamic or false if the body is static. (Defaults to true)
Returns Body
Lua: sm.body.createBody
inline Vector<Body> all(const World &world = {});Every body, optionally in one world.
Parameters
world(const World &): The world, will default to the script's world. (optional)
Returns Vector<Body>
Lua: sm.body.getAllBodies
inline Vector<Vector<Body>> creations(const Vector<Body> &bodies);Groups bodies by creation.
Parameters
bodies(const Vector<Body> &)
Returns Vector<Vector<Body>>
Lua: sm.body.getCreationsFromBodies
sm::json
Section titled "sm::json"JSON (sm.json).
inline Value parse(StringView text);Parses a JSON string.
Parameters
text(StringView): The json string.
Returns Value
Lua: sm.json.parseJsonString
inline String stringify(const Value &v, bool pretty = false);Converts a value to JSON.
Parameters
v(const Value &): The lua table.pretty(bool): Generates stylized json if true, compact if false. (Defaults to false)
Returns String
Lua: sm.json.writeJsonString
inline Value open(StringView path);Reads a JSON file. Paths use the usual prefixes: "$CONTENT_DATA/...".
Parameters
path(StringView)
Returns Value
Lua: sm.json.open
inline bool exists(StringView path);True if the file exists.
Parameters
path(StringView): The json file path.
Returns bool
Lua: sm.json.fileExists
inline void save(const Value &root, StringView path);Writes root (a table) as JSON. Only paths the game lets mods write, e.g. "$CONTENT_DATA/...".
Parameters
root(const Value &): The lua table.path(StringView): The json file path.
Lua: sm.json.save
sm::units
Section titled "sm::units"[server] AI units (sm.unit).
inline Unit create(const Uuid &uuid, Vec3 position, double yaw = 0, const Value &data = {});[server] Creates a unit of the character type uuid, feet at position, facing yaw radians.
Parameters
uuid(const Uuid &)position(Vec3)yaw(double)data(const Value &)
Returns Unit
Lua: sm.unit.createUnit
inline Vector<Unit> all();[server] Every unit.
Returns Vector<Unit>
Lua: sm.unit.getAllUnits
inline Vector<Unit> inRange(const World &world, Vec3 position, double range);[server] Units within range of a position.
Parameters
world(const World &)position(Vec3)range(double)
Returns Vector<Unit>
Lua: sm.unit.getUnitsInRange
inline void forceDestroy(const Unit &unit);[server] Destroys the unit right away, skipping its death logic.
Parameters
unit(const Unit &): The unit.
Lua: sm.unit.forceDestroy
sm::harvestables
Section titled "sm::harvestables"[server] Harvestables (sm.harvestable).
inline Harvestable create(const Uuid &uuid, Vec3 position, Quat rotation = {});[server] Creates a harvestable.
Parameters
uuid(const Uuid &)position(Vec3)rotation(Quat)
Returns Harvestable
Lua: sm.harvestable.createHarvestable
inline Vector<Harvestable> all();Every harvestable.
Returns Vector<Harvestable>
Lua: sm.harvestable.getAllHarvestables
inline Harvestable byInitialHash(double hash);The kinematic with this Harvestable::initialHash() (empty if none).
Parameters
hash(double): The initial hash to search for.
Returns Harvestable
Lua: sm.harvestable.getKinematicByInitialHash
sm::characters
Section titled "sm::characters"Characters (sm.character).
inline Character create(const Player &player, const World &world, Vec3 position, double yaw = 0, double pitch = 0);[server] Creates a character for a player in a world.
Parameters
player(const Player &)world(const World &)position(Vec3)yaw(double)pitch(double)
Returns Character
Lua: sm.character.createCharacter
sm::scriptableObjects
Section titled "sm::scriptableObjects"Scriptable objects (sm.scriptableObject).
inline ScriptableObject create(const Uuid &uuid, const Value ¶ms = {});[server] Creates a scriptable object.
Parameters
uuid(const Uuid &)params(const Value &)
Returns ScriptableObject
Lua: sm.scriptableObject.createScriptableObject
sm::container
Section titled "sm::container"Container transactions (sm.container).
template <class F> bool transaction(F body);[server] Runs body as one container transaction: collect / spend calls inside it apply
together. Returns false if the transaction couldn't start or didn't apply.
Parameters
body(F)
Returns bool
Lua: sm.container.beginTransaction
inline void abortTransaction();[server] Cancels the running transaction.
Lua: sm.container.abortTransaction
sm::storage
Section titled "sm::storage"Game-wide save data (sm.storage).
template <class T> void save(StringView key, const T &value);Saves a value under a key.
Parameters
key(StringView): The key that will be used to get the data.value(const T &): The data to be stored.
Lua: sm.storage.save
inline Value load(StringView key);Loads a value saved under a key.
Parameters
key(StringView): The key.
Returns Value
Lua: sm.storage.load
template <class T> void saveAndSync(StringView key, const T &value);Saves a value and also syncs it to clients.
Parameters
key(StringView): The key that will be used to get the data.value(const T &): The data to be stored.
Lua: sm.storage.saveAndSync
inline Value loadTerrainData(int worldId);The terrain data a world's terrain script saved.
Parameters
worldId(int): The id of the world to load terrain data for.
Returns Value
Lua: sm.storage.loadTerrainData