Skip to content

atl/client.hpp

Client-only APIs: the local player (sm.localPlayer) and the camera (sm.camera).

The player on this client.

inline Player player();

The local Player object.

Returns Player

Lua: sm.localPlayer.getPlayer

inline int id();

The local player's id.

Returns int

Lua: sm.localPlayer.getId

inline World world();

The world the local player is in.

Returns World

Lua: sm.localPlayer.getWorld

inline Vec3 position();

The local character's position, or zero when there is no character.

Returns Vec3

inline Vec3 direction();

The look direction and the directions to its right and up.

Returns Vec3

Lua: sm.localPlayer.getDirection

inline Vec3 right();

The look direction and the directions to its right and up.

Returns Vec3

Lua: sm.localPlayer.getRight

inline Vec3 up();

The look direction and the directions to its right and up.

Returns Vec3

Lua: sm.localPlayer.getUp

inline void setDirection(Vec3 d);

Turns the view to face direction d.

Parameters

  • d (Vec3): The world direction.

Lua: sm.localPlayer.setDirection

inline Optional<physics::RaycastHit> raycast(double range, Optional<Vec3> origin = atl::none, Optional<Vec3> direction = atl::none);

Raycasts from the player's view up to range meters; origin and direction default to the view.

Parameters

  • range (double): The maximum range.
  • origin (Optional<Vec3>): The start position. (Defaults to sm.localPlayer.getRaycastStart)
  • direction (Optional<Vec3>): The direction. (Defaults to sm.localPlayer.getDirection)

Returns Optional<physics::RaycastHit>

Lua: sm.localPlayer.getRaycast

inline Optional<physics::RaycastHit> latestRaycast();

The raycast the game made for the player's interaction this frame.

Returns Optional<physics::RaycastHit>

Lua: sm.localPlayer.getLatestRaycast

inline Vec3 raycastStart();

Where interaction raycasts start.

Returns Vec3

Lua: sm.localPlayer.getRaycastStart

inline Uuid activeItem();

The uuid of the item in the selected hotbar slot.

Returns Uuid

Lua: sm.localPlayer.getActiveItem

inline int selectedHotbarSlot();

The selected hotbar slot index.

Returns int

Lua: sm.localPlayer.getSelectedHotbarSlot

inline Container inventory();

The player's inventory, hotbar and carried-item containers.

Returns Container

Lua: sm.localPlayer.getInventory

inline Container hotbar();

The player's inventory, hotbar and carried-item containers.

Returns Container

Lua: sm.localPlayer.getHotbar

inline Container carry();

The player's inventory, hotbar and carried-item containers.

Returns Container

Lua: sm.localPlayer.getCarry

inline MouseDelta mouseDelta();

Reads this frame's mouse movement.

Returns MouseDelta

Lua: sm.localPlayer.getMouseDelta

inline double aimSensitivity();

The player's aim sensitivity setting.

Returns double

Lua: sm.localPlayer.getAimSensitivity

inline bool isInFirstPersonView();

True in first person view.

Returns bool

Lua: sm.localPlayer.isInFirstPersonView

inline bool wantsSprint();

True while the sprint input is held.

Returns bool

Lua: sm.localPlayer.getWantsSprint

inline void setLockedControls(bool locked);

Freezes movement and look input, e.g. while one of your menus is open.

Parameters

  • locked (bool)

Lua: sm.localPlayer.setLockedControls

inline void setBlockSprinting(bool block);

Prevents sprinting.

Parameters

  • block (bool): Sets whether sprinting is blocked.

Lua: sm.localPlayer.setBlockSprinting

inline void addRenderable(StringView rend);

Adds / removes a renderable drawn on the first person view model.

Parameters

  • rend (StringView): The renderable path.

Lua: sm.localPlayer.addRenderable

inline void removeRenderable(StringView rend);

Adds / removes a renderable drawn on the first person view model.

Parameters

  • rend (StringView): The renderable path.

Lua: sm.localPlayer.removeRenderable

inline void updateFpAnimation(StringView name, double time, Optional<double> weight = atl::none, bool looping = false);

Plays a first person animation at time with an optional blend weight.

Parameters

  • name (StringView): The name.
  • time (double): The time.
  • weight (Optional<double>): The weight. (Defaults to -1.0)
  • looping (bool): The looping. (Defaults to false)

Lua: sm.localPlayer.updateFpAnimation

inline Vec3 fpBonePosition(StringView bone);

World position of a bone of the first person model.

Parameters

  • bone (StringView)

Returns Vec3

Lua: sm.localPlayer.getFpBonePos

inline AnimationInfo fpAnimationInfo(StringView name);

Information about a first person animation.

Parameters

  • name (StringView): The name.

Returns AnimationInfo

Lua: sm.localPlayer.getFpAnimationInfo

inline Color carryColor();

The color of the carried item.

Returns Color

Lua: sm.localPlayer.getCarryColor

inline Lift ownedLift();

The lift the local player owns.

Returns Lift

Lua: sm.localPlayer.getOwnedLift

inline bool secondaryInteractBusy();

True while the equipped tool uses the secondary interaction (e.g. aiming).

Returns bool

Lua: sm.localPlayer.secondaryInteractBusy

inline Optional<Placement> constructionPlacement();

Where the shape being placed would go, or none when the player isn't placing.

Returns Optional<Placement>

Lua: sm.localPlayer.getConstructionPlacement

inline String garmentName(const Uuid &u);

A garment's (cosmetic's) name and its upper-case title.

Parameters

  • u (const Uuid &): The garment.

Returns String

Lua: sm.localPlayer.getGarmentName

inline String garmentUpperCaseTitle(const Uuid &u);

A garment's (cosmetic's) name and its upper-case title.

Parameters

  • u (const Uuid &): The garment.

Returns String

Lua: sm.localPlayer.getGarmentUpperCaseTitle

inline bool isGarmentUnlocked(const Uuid &u);

True if the player has unlocked a garment.

Parameters

  • u (const Uuid &): The garment.

Returns bool

Lua: sm.localPlayer.isGarmentUnlocked

inline void grantQuestItem(const Uuid &u);

Survival only: unlocks a cosmetic.

Parameters

  • u (const Uuid &): The uuid of the unlocked cosmetic.

Lua: sm.localPlayer.grantQuestItem

Mouse movement this frame.

struct MouseDelta
double x = 0, y = 0;

A position and rotation.

struct Placement
Vec3 position;
Quat rotation;

The game camera. Reading works anywhere; setters require a scripted state.

inline Vec3 position();

The camera's position, rotation and directions.

Returns Vec3

Lua: sm.camera.getPosition

inline Quat rotation();

The camera's position, rotation and directions.

Returns Quat

Lua: sm.camera.getRotation

inline Vec3 direction();

The camera's position, rotation and directions.

Returns Vec3

Lua: sm.camera.getDirection

inline Vec3 right();

The camera's position, rotation and directions.

Returns Vec3

Lua: sm.camera.getRight

inline Vec3 up();

The camera's position, rotation and directions.

Returns Vec3

Lua: sm.camera.getUp

inline double fov();

The current and default field of view in degrees.

Returns double

Lua: sm.camera.getFov

inline double defaultFov();

The current and default field of view in degrees.

Returns double

Lua: sm.camera.getDefaultFov

inline Vec3 defaultPosition();

The camera's default position and rotation.

Returns Vec3

Lua: sm.camera.getDefaultPosition

inline Quat defaultRotation();

The camera's default position and rotation.

Returns Quat

Lua: sm.camera.getDefaultRotation

inline int state();

The current state as a number (compare with State values).

Returns int

Lua: sm.camera.getCameraState

inline void setState(State s);

Switches camera state. Set a scripted state (e.g. State::CutsceneTP) to control position, rotation and fov; set State::Default to give control back.

Parameters

  • s (State): How the camera is moved. (See sm.camera.state)

Lua: sm.camera.setCameraState

inline void setState(StringView name);

Switches camera state by engine name (sm.camera.state[name]), for states not in the enum, e.g. "forcedFP".

Parameters

  • name (StringView): How the camera is moved. (See sm.camera.state)

Lua: sm.camera.setCameraState

inline void setPosition(Vec3 p);

Sets position, rotation, direction or fov while in a scripted state.

Parameters

  • p (Vec3): The camera's world position.

Lua: sm.camera.setPosition

inline void setRotation(Quat q);

Sets position, rotation, direction or fov while in a scripted state.

Parameters

  • q (Quat): The rotation of the camera.

Lua: sm.camera.setRotation

inline void setDirection(Vec3 d);

Sets position, rotation, direction or fov while in a scripted state.

Parameters

  • d (Vec3): The direction of the camera's aim.

Lua: sm.camera.setDirection

inline void setFov(double fov);

Sets position, rotation, direction or fov while in a scripted state.

Parameters

  • fov (double): The field of view.

Lua: sm.camera.setFov

inline void shake(double strength);

Shakes the camera with the given strength.

Parameters

  • strength (double): The camera shake strength.

Lua: sm.camera.setShake

inline void setPullback(int step, int seatedStep);

Sets the third person zoom steps (on foot / seated).

Parameters

  • step (int): How far away the camera is from the player while standing
  • seatedStep (int): How far away the camera is from the player while seated

Lua: sm.camera.setCameraPullback

inline Pullback pullback();

Reads the third person zoom steps.

Returns Pullback

Lua: sm.camera.getCameraPullback

inline void setSeatLockedPullback(double distance);

Settings for State::SeatLockedCamera: pullback distance, up offset and local orientation.

Parameters

  • distance (double): The pullback distance.

Lua: sm.camera.setSeatLockedCameraPullback

inline void setSeatLockedUpOffset(double offset);

Settings for State::SeatLockedCamera: pullback distance, up offset and local orientation.

Parameters

  • offset (double): The up offset in local space.

Lua: sm.camera.setSeatLockedCameraUpOffset

inline void setSeatLockedLocalDirection(Vec3 d);

Settings for State::SeatLockedCamera: pullback distance, up offset and local orientation.

Parameters

  • d (Vec3): The local direction to face.

Lua: sm.camera.setSeatLockedLocalDirection

inline void setSeatLockedLocalUp(Vec3 up);

Settings for State::SeatLockedCamera: pullback distance, up offset and local orientation.

Parameters

  • up (Vec3): The local up direction.

Lua: sm.camera.setSeatLockedLocalUp

inline void setUnseatDirection(Optional<Vec3> worldDirection = atl::none);

Which way the character faces after leaving the seat (none for the default).

Parameters

  • worldDirection (Optional<Vec3>): The world-space direction to face on unseat. (optional)

Lua: sm.camera.setUnseatDirection

inline double sphereCast(double radius, Vec3 start, Vec3 direction);

How far a sphere can travel from start along direction before hitting something.

Parameters

  • radius (double): The radius of the cast sphere
  • start (Vec3): The start position.
  • direction (Vec3): The cast direction and range.

Returns double

Lua: sm.camera.cameraSphereCast

Camera modes (sm.camera.state).

enum class State : int {
Default = 1,
CutsceneFP = 2,
CutsceneTP = 3,
ForcedTP = 4,
GyroSeatFP = 5,
GyroSeatTP = 6,
ScriptedTP = 7,
SeatLockedCamera = 8,
};

Third person zoom steps.

struct Pullback
int step = 0, seatedStep = 0;