Skip to content

atl/world.hpp

Worlds and what's in them: sm.world, sm.portal, sm.cell, sm.event, sm.message, sm.creation, sm.construction, sm.lift, sm.garage, sm.pipeGraph, sm.fire, sm.compromised, sm.challenge, sm.menuCreation, sm.achievement, sm.tool and sm.clientScriptableObject.

A blueprint import area, like the survival garage.

class Garage : public atl::Object
Vec3 position() const;

The garage's position.

Returns Vec3

Lua: Garage:getPosition

Aabb bounds() const;

The garage's bounds.

Returns Aabb

Lua: Garage:getGarageBounds

bool hasActiveTracking() const;

True while a blueprint is tracked.

Returns bool

Lua: Garage:hasActiveTracking

int trackingRevision() const;

Changes each time the tracked blueprint changes.

Returns int

Lua: Garage:getTrackingRevision

void trackBlueprint(StringView path) const;

[client] Tracks a blueprint and syncs it to the other clients.

Parameters

  • path (StringView): The blueprint path.

Lua: Garage:trackBlueprint

void untrackBlueprint() const;

Stops tracking.

Lua: Garage:untrackBlueprint

Blueprint trackedBlueprint() const;

Reads the tracked blueprint.

Returns Blueprint

Aabb blueprintBounds() const;

The tracked blueprint's bounds.

Returns Aabb

Lua: Garage:getBlueprintBounds

Optional<bool> creationFits() const;

Whether the tracked creation fits; empty when nothing is tracked.

Returns Optional<bool>

Optional<Vec3> placement() const;

Where the creation would be placed.

Returns Optional<Vec3>

void importBlueprint() const;

Imports the tracked blueprint.

Lua: Garage:importBlueprint

The tracked blueprint's name and contents.

struct Blueprint
String name;
Value json;

Creating and finding worlds.

inline World create(StringView scriptPath, StringView className, const Value &terrainParams = {}, Optional<int> seed = atl::none);

[server] Creates a world running script class className from scriptPath, e.g. worlds::create("$CONTENT_DATA/Scripts/World.lua", "World").

Parameters

  • scriptPath (StringView): The world script filename.
  • className (StringView): The world script class name.
  • terrainParams (const Value &): The world's terrain parameters. (Optional)
  • seed (Optional<int>): The world's seed. Defaults to 0 (Optional)

Returns World

Lua: sm.world.createWorld

inline bool load(const World &w);

[server] Loads a world created earlier (e.g. one kept in storage).

Parameters

  • w (const World &): The world that should be loaded.

Returns bool

Lua: sm.world.loadWorld

inline World current();

The world the running script is in.

Returns World

Lua: sm.world.getCurrentWorld

inline World legacyCreativeWorld();

[server] The world of a legacy creative save.

Returns World

Lua: sm.world.getLegacyCreativeWorld

inline Vector<DirtySphere> dirtySpheres(Optional<Vec3> position = atl::none, Optional<double> radius = atl::none);

Spheres where something changed in the world (optionally only near position).

Parameters

  • position (Optional<Vec3>): The world position of the sphere. (Optional)
  • radius (Optional<double>): The radius of the sphere. (Optional)

Returns Vector<DirtySphere>

Lua: sm.world.getDirtySpheres

A region where something changed.

struct DirtySphere
Vec3 center;
double radius = 0;

[server] Portals between worlds (see sm::Portal).

inline Portal create(Vec3 dimensions);

[server] Creates a portal with the given dimensions.

Parameters

  • dimensions (Vec3): The dimensions of the portal box.

Returns Portal

Lua: sm.portal.createPortal

inline void destroy(const Portal &p);

[server] Destroys a portal.

Parameters

  • p (const Portal &): The portal to be destroyed.

Lua: sm.portal.destroy

inline void addWorldHook(const World &world, StringView name, const Portal &portal);

[server] Leaves portal for a world created later to find with popWorldHook(name).

Parameters

  • world (const World &): The target world.
  • name (StringView): The portal name.
  • portal (const Portal &): The portal.

Lua: sm.portal.addWorldPortalHook

inline Portal popWorldHook(StringView name, const World &world = {});

[server] Takes the portal left under name by addWorldHook.

Parameters

  • name (StringView): The portal name.
  • world (const World &): The world to look in (Optional, defaults to world from script context)

Returns Portal

Lua: sm.portal.popWorldPortalHook

inline bool transferBToB(const Portal &from, const Portal &to, Optional<int> filter = atl::none);

[server] Moves what is in portal from to portal to.

Parameters

  • from (const Portal &): The portal to transfer from.
  • to (const Portal &): The portal to transfer to.
  • filter (Optional<int>): A sm.physics.filter mask 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: sm.portal.transferBToB

inline Optional<BestPortal> findBestToWorld(int playerWorldId, int targetWorldId, Vec3 from);

The portal with the shortest path from from (in world playerWorldId) to world targetWorldId.

Parameters

  • playerWorldId (int): The player's current world id.
  • targetWorldId (int): The world id we wanna get a path towards.
  • from (Vec3): The position we wanna get a path from.

Returns Optional<BestPortal>

Lua: sm.portal.findBestPortalToWorld

A portal and the position to walk to.

struct BestPortal
Vec3 position;
Portal portal;

Contents of a cell, by cell coordinates.

inline Vector<Harvestable> harvestables(int x, int y, Optional<int> size = atl::none);

[server] The harvestables in a cell.

Parameters

  • x (int): The X-coordinate.
  • y (int): The Y-coordinate.
  • size (Optional<int>): Size of harvestable (defaults to any size).

Returns Vector<Harvestable>

Lua: sm.cell.getHarvestables

inline Vector<Harvestable> harvestablesByUuid(int x, int y, const Uuid &uuid, Optional<int> size = atl::none);

[server] The harvestables of one uuid in a cell.

Parameters

  • x (int): The X-coordinate.
  • y (int): The Y-coordinate.
  • uuid (const Uuid &): The uuid of the harvestable(s)
  • size (Optional<int>): Size of harvestable (defaults to any size).

Returns Vector<Harvestable>

Lua: sm.cell.getHarvestablesByUuid

inline Vector<Interactable> interactablesByUuid(int x, int y, const Uuid &uuid);

[server] The interactables of one uuid in a cell.

Parameters

  • x (int): The X-coordinate.
  • y (int): The Y-coordinate.
  • uuid (const Uuid &): The uuid of the interactable(s)

Returns Vector<Interactable>

Lua: sm.cell.getInteractablesByUuid

inline Vector<Interactable> interactablesByAnyUuid(int x, int y, const Vector<Uuid> &uuids);

[server] The interactables matching any of the uuids.

Parameters

  • x (int): The X-coordinate.
  • y (int): The Y-coordinate.
  • uuids (const Vector<Uuid> &)

Returns Vector<Interactable>

Lua: sm.cell.getInteractablesByAnyUuid

inline Vector<Interactable> interactablesByTag(int x, int y, StringView tag);

[server] The interactables with a tag.

Parameters

  • x (int): The X-coordinate.
  • y (int): The Y-coordinate.
  • tag (StringView): A tag to match with.

Returns Vector<Interactable>

Lua: sm.cell.getInteractablesByTag

inline Vector<Interactable> interactablesByTags(int x, int y, const Vector<String> &tags);

[server] The interactables with all of these tags.

Parameters

  • x (int): The X-coordinate
  • y (int): The Y-coordinate
  • tags (const Vector<String> &)

Returns Vector<Interactable>

Lua: sm.cell.getInteractablesByTags

inline Value nodesByTag(int x, int y, StringView tag, const World &world = {});

Terrain nodes with a tag: tables with position, rotation, scale, params, tags.

Parameters

  • x (int)
  • y (int)
  • tag (StringView): Tag to match with.
  • world (const World &): The world we are searching in. (Optional, defaults to current world)

Returns Value

Lua: sm.cell.getNodesByTag

inline Value nodesByTags(int x, int y, const Vector<String> &tags, const World &world = {});

Terrain nodes with all of these tags.

Parameters

  • x (int)
  • y (int)
  • tags (const Vector<String> &)
  • world (const World &): The world we are searching in (Optional, defaults to current world)

Returns Value

Lua: sm.cell.getNodesByTags

inline Vector<String> tags(int x, int y, const World &world = {});

The cell's tags.

Parameters

  • x (int)
  • y (int)
  • world (const World &): The world we are searching in. (Optional, defaults to current world)

Returns Vector<String>

Lua: sm.cell.getTags

Calls method callback(args) on another object's script. Network rules apply: a server call reaches the server side, a client call the client side. For a C++ script, callback is a name registered with .method<>(). Each function returns true if the event was sent.

template <class T = atl::Nil> bool toGame(StringView callback, const T &args = {}, const Options &o = {});

Sends to the game script.

Parameters

  • callback (StringView)
  • args (const T &)
  • o (const Options &)

Returns bool

Lua: sm.event.sendToGame

template <class T = atl::Nil> bool toWorld(const World &w, StringView callback, const T &args = {}, const Options &o = {});

Sends to a world's script.

Parameters

  • w (const World &)
  • callback (StringView)
  • args (const T &)
  • o (const Options &)

Returns bool

Lua: sm.event.sendToWorld

template <class T = atl::Nil> bool toPlayer(const Player &p, StringView callback, const T &args = {}, const Options &o = {});

Sends to a player's script.

Parameters

  • p (const Player &)
  • callback (StringView)
  • args (const T &)
  • o (const Options &)

Returns bool

Lua: sm.event.sendToPlayer

template <class T = atl::Nil> bool toCharacter(const Character &c, StringView callback, const T &args = {}, const Options &o = {});

Sends to a character's script.

Parameters

  • c (const Character &)
  • callback (StringView)
  • args (const T &)
  • o (const Options &)

Returns bool

Lua: sm.event.sendToCharacter

template <class T = atl::Nil> bool toInteractable(const Interactable &i, StringView callback, const T &args = {}, const Options &o = {});

Sends to an interactable's script.

Parameters

  • i (const Interactable &)
  • callback (StringView)
  • args (const T &)
  • o (const Options &)

Returns bool

Lua: sm.event.sendToInteractable

template <class T = atl::Nil> bool toHarvestable(const Harvestable &h, StringView callback, const T &args = {}, const Options &o = {});

Sends to a harvestable's script.

Parameters

  • h (const Harvestable &)
  • callback (StringView)
  • args (const T &)
  • o (const Options &)

Returns bool

Lua: sm.event.sendToHarvestable

template <class T = atl::Nil> bool toUnit(const Unit &u, StringView callback, const T &args = {}, const Options &o = {});

Sends to a unit's script.

Parameters

  • u (const Unit &)
  • callback (StringView)
  • args (const T &)
  • o (const Options &)

Returns bool

Lua: sm.event.sendToUnit

template <class T = atl::Nil> bool toTool(const Tool &t, StringView callback, const T &args = {}, const Options &o = {});

Sends to a tool's script.

Parameters

  • t (const Tool &)
  • callback (StringView)
  • args (const T &)
  • o (const Options &)

Returns bool

Lua: sm.event.sendToTool

template <class T = atl::Nil> bool toScriptableObject(const ScriptableObject &so, StringView callback, const T &args = {}, const Options &o = {});

Sends to a scriptable object's script.

Parameters

  • so (const ScriptableObject &)
  • callback (StringView)
  • args (const T &)
  • o (const Options &)

Returns bool

Lua: sm.event.sendToScriptableObject

Optional event settings.

struct Options
Optional<int> eventType;
Optional<bool> pauseSave;

[server] Publish/subscribe between scripts.

template <class T = atl::Nil> void send(StringView key, const T &data = {});

[server] Sends data to every script subscribed to key.

Parameters

  • key (StringView): The message key.
  • data (const T &): Optional data to send with the message.

Lua: sm.message.send

inline void subscribe(StringView key, atl::Function<void(Value args)> fn);

[server] Makes the running script receive every message sent with key (engine-defined arguments).

Parameters

  • key (StringView): The message key to subscribe to.
  • fn (atl::Function<void (Value)>): The name of the callback function to invoke.

Lua: sm.message.subscribe

Importing and exporting blueprints.

inline Vector<Body> importFromFile(const World &world, StringView path, const ImportOptions &o = {}, Optional<bool> indestructible = atl::none);

[server] Imports a blueprint file into a world, returning its bodies.

Parameters

  • world (const World &)
  • path (StringView)
  • o (const ImportOptions &)
  • indestructible (Optional<bool>)

Returns Vector<Body>

Lua: sm.creation.importFromFile

inline Vector<Body> importFromString(const World &world, StringView json, const ImportOptions &o = {}, Optional<bool> forceInactive = atl::none);

[server] Imports blueprint JSON into a world, returning its bodies.

Parameters

  • world (const World &)
  • json (StringView)
  • o (const ImportOptions &)
  • forceInactive (Optional<bool>)

Returns Vector<Body>

Lua: sm.creation.importFromString

inline String exportToString(const Body &body, bool exportTransforms = false, bool forceDynamic = false);

[server] The creation body belongs to, as blueprint JSON / a Lua table.

Parameters

  • body (const Body &): Any body in the creation.
  • exportTransforms (bool): Export the current world transform of bodies. Defaults to false.
  • forceDynamic (bool): Force export to dynamic bodies. Defaults to false.

Returns String

Lua: sm.creation.exportToString

inline Value exportToTable(const Body &body, bool exportTransforms = false, bool forceDynamic = false);

[server] The creation body belongs to, as blueprint JSON / a Lua table.

Parameters

  • body (const Body &): Any body in the creation.
  • exportTransforms (bool): Export the current world transform of bodies. Defaults to false.
  • forceDynamic (bool): Force export to dynamic bodies. Defaults to false.

Returns Value

Lua: sm.creation.exportToTable

inline Value blueprintCost(StringView path, Optional<int> bodyId = atl::none);

{ [uuid] = quantity } to build a blueprint (from a file path or a blueprint table).

Parameters

  • path (StringView): The lua table for the blueprint.
  • bodyId (Optional<int>): The id of a body.(Optional)

Returns Value

Lua: sm.creation.getBlueprintCost

inline Value blueprintCost(const Value &blueprint, Optional<int> bodyId = atl::none);

{ [uuid] = quantity } to build a blueprint (from a file path or a blueprint table).

Parameters

  • blueprint (const Value &): The lua table for the blueprint.
  • bodyId (Optional<int>): The id of a body.(Optional)

Returns Value

Lua: sm.creation.getBlueprintCost

inline void buildMultiShape(const Uuid &shape, Vec3 worldPosition, Quat worldRotation, Optional<Vec3> localPosition = atl::none, Optional<Quat> localRotation = atl::none);

[server] Builds a multi-shape item at a world position.

Parameters

  • shape (const Uuid &): The uuid of shape to build.
  • worldPosition (Vec3): World position of shape.
  • worldRotation (Quat): World rotation of shape.
  • localPosition (Optional<Vec3>): Local position of shape.
  • localRotation (Optional<Quat>): Local rotation of shape.

Lua: sm.creation.buildMultiShape

Where to place an imported blueprint.

struct ImportOptions
Optional<Vec3> position;
Optional<Quat> rotation;
Optional<bool> importTransforms;

Keep the blueprint's own transforms.

Building blocks onto a Lift, Shape or Joint.

template <class On> void buildBlock(const Uuid &uuid, Vec3 localPosition, const On &on);

[server] Places a block at a local position on on.

Parameters

  • uuid (const Uuid &): The uuid of the block to build.
  • localPosition (Vec3): The position to build the block on.
  • on (const On &)

Lua: sm.construction.buildBlock

template <class On> bool validateLocalPosition(const Uuid &uuid, Vec3 localPosition, Vec3 localNormal, const On &on);

True if a block could be placed there.

Parameters

  • uuid (const Uuid &): The uuid of the shape to validate.
  • localPosition (Vec3): The position local to the body.
  • localNormal (Vec3): The normal of the surface to validate placement.
  • on (const On &): The object to build on.

Returns bool

Lua: sm.construction.validateLocalPosition

[server] Lifts not owned by a player.

inline void createNonPlayer(const World &world, Vec3 position, const Body &body = {}, Optional<int> level = atl::none, Optional<int> rotation = atl::none);

[server] Creates a lift nobody owns.

Parameters

  • world (const World &): World to place the lift in.
  • position (Vec3): Position to place the lift at.
  • body (const Body &): Body to place on the lift (optional).
  • level (Optional<int>): Level to place the lift at. (Defaults to 0.)
  • rotation (Optional<int>): Rotation index to place the lift at. (Defaults to 0.)

Lua: sm.lift.createNonPlayerLift

inline void createVirtual(const World &world, const Body &body);

[server] Creates an invisible lift holding body (Body::isOnVirtualLift).

Parameters

  • world (const World &): World to place the lift in.
  • body (const Body &): Body to place on the lift.

Lua: sm.lift.createVirtualLift

inline Garage create(int id, const World &world, Vec3 halfExtents, Vec3 position);

Creates a garage.

Parameters

  • id (int): The id of the garage to create
  • world (const World &): The world the garage is in
  • halfExtents (Vec3): Half extents of the spawnbox inside the garage
  • position (Vec3): Position of the spawn box inside the garage

Returns Garage

Lua: sm.garage.createGarage

inline Garage get(int id);

A garage by id.

Parameters

  • id (int): The id of the garage to get

Returns Garage

Lua: sm.garage.getGarage

Pipe networks between containers. requester is the shape asking.

inline Vector<Shape> inputContainers(const Shape &requester);

Containers piped into / out of the requester.

Parameters

  • requester (const Shape &): The shape connected to the pipe graph who's connected chests you want.

Returns Vector<Shape>

Lua: sm.pipeGraph.getInputContainers

inline Vector<Shape> outputContainers(const Shape &requester);

Containers piped into / out of the requester.

Parameters

  • requester (const Shape &): The shape connected to the pipe graph who's connected chests you want.

Returns Vector<Shape>

Lua: sm.pipeGraph.getOutputContainers

inline Vector<Container> matchingPipedContainers(const Interactable &origin);

Piped containers that match the origin's.

Parameters

  • origin (const Interactable &): The interactable where the search will start from.

Returns Vector<Container>

Lua: sm.pipeGraph.getMatchingPipedContainers

inline Shape containerToCollectTo(const Shape &requester, const Vector<Item> &items);

A container shape with room for all of items.

Parameters

  • requester (const Shape &)
  • items (const Vector<Item> &)

Returns Shape

Lua: sm.pipeGraph.getContainerShapeToCollectTo

inline Shape containerToSpendFrom(const Shape &requester, const Uuid &item, int quantity);

A container shape holding quantity of item.

Parameters

  • requester (const Shape &): The shape connected to the pipe graph who requests the information.
  • item (const Uuid &): The uuid of the target item.
  • quantity (int): The target spending amount.

Returns Shape

Lua: sm.pipeGraph.getContainerShapeToSpendFrom

inline Vector<Shape> containerPath(const Shape &requester, const Shape &target, Optional<int> direction = atl::none);

[client] The pipes between two shapes.

Parameters

  • requester (const Shape &): The requesting shape.
  • target (const Shape &): The target container shape.
  • direction (Optional<int>): The direction to fetch in. Defaults to [sm.pipeGraph.direction, sm.pipeGraph.direction.any] (Optional)

Returns Vector<Shape>

Lua: sm.pipeGraph.getContainerPath

inline void requestLightingOverride(const Shape &requester, const Shape &target, int uvIndex, double glow);

[client] Overrides pipe glow and UV while items move through them.

Parameters

  • requester (const Shape &): The requesting shape.
  • target (const Shape &): The target container shape.
  • uvIndex (int): The uv frame index for the affected pipes. Ranges 0 to 3.
  • glow (double): The glow multiplier of the pipes.

Lua: sm.pipeGraph.requestLightingOverride

inline void releaseLightingOverride(const Shape &requester);

[client] Ends a lighting override.

Parameters

  • requester (const Shape &): The requesting shape.

Lua: sm.pipeGraph.releaseLightingOverride

inline void setAutomatedTask(const Shape &requester, const Value &recipe, Optional<bool> parallel = atl::none);

[server] Crafting while the body is unloaded: recipe is a recipe table.

Parameters

  • requester (const Shape &): The shape which requests the automated process.
  • recipe (const Value &): A table with information on the recipe. Uses the crafter recipe format. Can have "craftTime", "quantity", "itemId", "externalContainers"(containers targeted outside pipe graph for consumption, example: refinery), "selfOutputContainer"(if the shape has it's own collection container), "ingredientList", "randomCraftList" random weighted crafts (see prospector), "specialCrafting" used to target specific container slots with custom information (see ore crusher).
  • parallel (Optional<bool>): Whether the craft tasks should be carried out in parallel or not, off by default. A parallel task will be carried out independently of other automated tasks on this shape. (Optional)

Lua: sm.pipeGraph.setAutomatedTask

inline void removeAutomatedTask(const Shape &requester, const Uuid &item);

[server] Removes one automated task, or all of them.

Parameters

  • requester (const Shape &): The requesting shape.
  • item (const Uuid &): The production to stop.

Lua: sm.pipeGraph.removeAutomatedTask

inline void removeAutomatedTasks(const Shape &requester);

[server] Removes one automated task, or all of them.

Parameters

  • requester (const Shape &): The requesting shape.

Lua: sm.pipeGraph.removeAutomatedTasks

inline void setParallelLimit(const Shape &requester, int amount);

[server] How many automated tasks may run at once.

Parameters

  • requester (const Shape &): The requesting shape.
  • amount (int): The number of parallel crafts allowed to be done at once.

Lua: sm.pipeGraph.setParallelLimit

inline void setInteractableCondition(const Shape &requester, const Value &condition);

[server] Sets the conditions an interactable must meet to craft (a condition table).

Parameters

  • requester (const Shape &): The requesting shape.
  • condition (const Value &): Values for special conditions to allow crafting. Uses "uuid", "tickFrequency", "remainingTicks"(optional), "consumptionCount", "onlyExternal". See Prospector.lua for example.

Lua: sm.pipeGraph.setInteractableCondition

inline Value interactableConditionTicks(const Shape &requester);

[server] What's left of the interactable's conditions.

Parameters

  • requester (const Shape &): The requesting shape.

Returns Value

Lua: sm.pipeGraph.getInteractableConditionTicks

[server] Fire.

inline bool isAreaBurning(Vec3 position, double radius, const World &world);

[server] True if anything burns in the sphere.

Parameters

  • position (Vec3): The position of the sphere.
  • radius (double): The radius of the sphere.
  • world (const World &): The world to check for fire in.

Returns bool

Lua: sm.fire.isAreaBurning

inline void igniteSphere(Vec3 position, double radius, Optional<bool> flag = atl::none, const World &world = {});

[server] Sets fire to the sphere.

Parameters

  • position (Vec3): The position of the sphere.
  • radius (double): The radius of the sphere.
  • flag (Optional<bool>): Undocumented. Optional.
  • world (const World &): The world to ignite fire in. (Optional, defaults to world from script context)

Lua: sm.fire.igniteSphere

inline Vector<Shape> burningShapes();

[server] Every burning shape.

Returns Vector<Shape>

Lua: sm.fire.getBurningShapes

inline void setLimit(int limit);

[server] The maximum number of fire instances.

Parameters

  • limit (int): The limit of fire instances.

Lua: sm.fire.setFireLimit

[server] Compromised (structurally weakened) shapes.

inline bool compromiseShapeInSphere(Vec3 position, double radius);

[server] Compromises a shape in the sphere; true if one was found.

Parameters

  • position (Vec3): The center position of the sphere.
  • radius (double): The radius of the sphere.

Returns bool

Lua: sm.compromised.compromiseShapeInSphere

inline Vector<Shape> shapes(const World &world = {});

[server] Every compromised shape.

Parameters

  • world (const World &): The world to check for compromised shapes in. (Optional, defaults to world from script context)

Returns Vector<Shape>

Lua: sm.compromised.getCompromisedShapes

inline bool any(const World &world);

[server] True if the world has compromised shapes.

Parameters

  • world (const World &): The world to check for compromised shapes in.

Returns bool

Lua: sm.compromised.hasCompromisedShapes

Challenge mode. All [server] except isMasterMechanicTrial.

inline void start(const World &world);

[server] Starts / stops the challenge.

Parameters

  • world (const World &)

Lua: sm.challenge.start

inline void stop();

[server] Starts / stops the challenge.

Lua: sm.challenge.stop

inline bool hasStarted();

[server] True once started.

Returns bool

Lua: sm.challenge.hasStarted

inline void levelCompleted(const Uuid &level, double time, const Value &save);

[server] Records a completed level with its time and save data.

Parameters

  • level (const Uuid &): The level's uuid.
  • time (double): The completion time.
  • save (const Value &): A table containing save data.

Lua: sm.challenge.levelCompleted

inline double completionTime(const Uuid &level);

[server] A level's best completion time.

Parameters

  • level (const Uuid &): The level's uuid.

Returns double

Lua: sm.challenge.getCompletionTime

inline Value saveData(const Uuid &level);

[server] A level's saved data.

Parameters

  • level (const Uuid &): The level's uuid.

Returns Value

Lua: sm.challenge.getSaveData

inline String resolveContentPath(StringView path);

[server] Turns a "$CONTENT_DATA/..." path into one the main game can open.

Parameters

  • path (StringView): The path containing $CONTENT_DATA.

Returns String

Lua: sm.challenge.resolveContentPath

inline void takePicture(int width, int height, int rotation);

[server] Takes a screenshot for the level.

Parameters

  • width (int): Preview width.
  • height (int): Preview height.
  • rotation (int): Rotation step.

Lua: sm.challenge.takePicture

inline void takePicturesForMenu();

[server] Takes the menu screenshots.

Lua: sm.challenge.takePicturesForMenu

inline bool isMasterMechanicTrial();

[client] True in a Master Mechanic trial.

Returns bool

Lua: sm.challenge.isMasterMechanicTrial

[server] The creation shown in the main menu.

inline Value load();

[server] Loads the saved menu creation.

Returns Value

Lua: sm.menuCreation.load

inline void save(const Vector<String> &blueprints);

[server] Saves blueprints as the menu creation.

Parameters

  • blueprints (const Vector<String> &)

Lua: sm.menuCreation.save

Steam achievements and stats (official content only). playerIds defaults to everyone.

inline void addFloat(StringView uuid, double value, Optional<Vector<int>> playerIds = atl::none);

Adds to / sets a float or integer stat.

Parameters

  • uuid (StringView)
  • value (double)
  • playerIds (Optional<Vector<int>>)

Lua: sm.achievement.addf

inline void addInt(StringView uuid, int value, Optional<Vector<int>> playerIds = atl::none);

Adds to / sets a float or integer stat.

Parameters

  • uuid (StringView)
  • value (int)
  • playerIds (Optional<Vector<int>>)

Lua: sm.achievement.addi

inline void setFloat(StringView uuid, double value, Optional<Vector<int>> playerIds = atl::none);

Adds to / sets a float or integer stat.

Parameters

  • uuid (StringView)
  • value (double)
  • playerIds (Optional<Vector<int>>)

Lua: sm.achievement.setf

inline void setInt(StringView uuid, int value, Optional<Vector<int>> playerIds = atl::none);

Adds to / sets a float or integer stat.

Parameters

  • uuid (StringView)
  • value (int)
  • playerIds (Optional<Vector<int>>)

Lua: sm.achievement.seti

inline void pushToContext(StringView name, const Value &data, Optional<Vector<int>> playerIds = atl::none);

Pushes data to an achievement context.

Parameters

  • name (StringView)
  • data (const Value &)
  • playerIds (Optional<Vector<int>>)

Lua: sm.achievement.pushToContext

Tool helpers (lift placement, paint palette, forced tools).

inline bool exists(const Uuid &uuid);

True if a tool with this uuid exists.

Parameters

  • uuid (const Uuid &): The tool uuid.

Returns bool

Lua: sm.tool.uuidExists

inline int liftMaxLevel();

The highest lift level.

Returns int

Lua: sm.tool.getLiftMaxLevel

inline LiftCheck checkLiftCollision(const Vector<Body> &creation, Vec3 position, int rotation);

Whether a lift carrying creation at position would collide, and at which level it would sit.

Parameters

  • creation (const Vector<Body> &)
  • position (Vec3)
  • rotation (int)

Returns LiftCheck

Lua: sm.tool.checkLiftCollision

inline bool checkLiftCollisionAtLevel(const Vector<Body> &creation, Vec3 position, int rotation, int level, int timeStamp);

Whether a lift carrying creation would collide at a specific level.

Parameters

  • creation (const Vector<Body> &): A table of all the bodies belonging to the creation placed on the lift.
  • position (Vec3): The lift position.
  • rotation (int): The rotation of the creation on the lift.
  • level (int): The specific lift level to test.
  • timeStamp (int): The timestamp of when the body set was initialized

Returns bool

Lua: sm.tool.checkLiftCollisionAtLevel

inline int paintPaletteColumn(uint32_t uintRgba);

The paint tool palette column closest to a color (Color::uintRgba()).

Parameters

  • uintRgba (uint32_t): The UintRgba version of the color (Color:getUnitRgba()).

Returns int

Lua: sm.tool.findPaintToolPaletteColumnIndex

inline void force(const Tool &t);

[client] Forces the local player to hold t until unforce().

Parameters

  • t (const Tool &)

Lua: sm.tool.forceTool

inline void unforce();

[client] Releases a forced tool.

Lua: sm.tool.forceTool

inline void preloadRenderables(const Vector<String> &rends);

[client] Loads renderables ahead of use.

Parameters

  • rends (const Vector<String> &)

Lua: sm.tool.preloadRenderables

Result of checkLiftCollision.

struct LiftCheck
bool collides = false;
int level = 0;
inline ClientScriptableObject create(const Uuid &uuid, const Value &params = {}, const World &world = {});

[client] Creates a scriptable object only this client has.

Parameters

  • uuid (const Uuid &): ScriptableObject uuid.
  • params (const Value &): self.params on scriptable object.
  • world (const World &): The world this script belongs to, for world dependent api calls. Defaults to [sm.world.ids, sm.world.ids.noWorld]

Returns ClientScriptableObject

Lua: sm.clientScriptableObject.createScriptableObject