atl::sm
The core Scrap Mechanic API: game object types (Shape, Body, Interactable, Character, Player, World, ...) and the sm.* namespaces that operate on them.
object!(pub Shape = "Shape" )A block or part in the world (Lua Shape).
Methods
pub fn sticky(&self) -> StickyThe sticky directions.
pub fn local_aabb(&self) -> AabbThe bounding box in body-local coordinates.
pub fn destroy_with(&self, d: &Destruction)[server] Destroys the shape with full destruction details.
pub fn new(v: Value) -> SelfWraps a Lua value.
pub fn value(&self) -> &ValueThe wrapped Lua value.
pub fn is_nil(&self) -> boolTrue for nil.
pub fn exists(&self) -> boolTrue when the object still exists in the game (sm.exists).
pub fn id(&self) -> i32The shape's unique id.
pub fn uuid(&self) -> UuidThe shape's item uuid.
pub fn world_position(&self) -> Vec3Position and rotation in the world, and relative to the body.
pub fn world_rotation(&self) -> Quatpub fn local_position(&self) -> Vec3pub fn local_rotation(&self) -> Quatpub fn velocity(&self) -> Vec3Velocity in meters per second.
pub fn at(&self) -> Vec3The shape's forward (at), up and right directions in the world.
pub fn up(&self) -> Vec3pub fn right(&self) -> Vec3pub fn x_axis(&self) -> Vec3The shape's local x, y and z axes in world space.
pub fn y_axis(&self) -> Vec3pub fn z_axis(&self) -> Vec3pub fn bounding_box(&self) -> Vec3Size in blocks.
pub fn mass(&self) -> f64Mass in kilograms.
pub fn material(&self) -> StringThe physics material name.
pub fn color(&self) -> ColorThe paint color.
pub fn set_color(&self, c: Color)[server] Paints the shape.
pub fn burning(&self) -> boolTrue while the shape burns.
pub fn set_burning(&self, b: bool)[server] Sets the shape on fire or puts it out.
pub fn transform_point(&self, world_point: Vec3) -> Vec3World point / direction to shape-local.
pub fn transform_direction(&self, world_dir: Vec3) -> Vec3pub fn transform_local_point(&self, local_point: Vec3) -> Vec3Shape-local point / direction to world.
pub fn transform_local_direction(&self, local_dir: Vec3) -> Vec3pub fn neighbours(&self) -> Vec<Shape>[server] Shapes touching this one.
pub fn interpolated_world_position(&self) -> Vec3Positions and directions smoothed between physics ticks, for rendering.
pub fn interpolated_at(&self) -> Vec3pub fn interpolated_up(&self) -> Vec3pub fn interpolated_right(&self) -> Vec3pub fn transform_rotation(&self, world_rotation: Quat) -> QuatA world rotation in shape-local terms.
pub fn closest_block_local_position(&self, world_position: Vec3) -> Vec3The local position of the shape's block nearest to a world position.
pub fn buoyancy(&self) -> f64Buoyancy of the shape's material.
pub fn material_id(&self) -> i32The physics material id.
pub fn set_physics_material(&self, material: i32)[client] Overrides the physics material.
pub fn set_collision_sound_enabled(&self, on: bool)Turns collision sounds on or off.
pub fn is_harvest(&self) -> boolTrue for a harvested item.
pub fn is_stackable(&self) -> boolTrue if the item stacks.
pub fn compromised(&self) -> boolTrue when the shape is structurally weakened.
pub fn set_compromised(&self, on: bool)[server] Weakens or restores the shape.
pub fn remove_color(&self)[server] Back to the shape's default color.
pub fn apply_shake_impulse(&self, shake: f64)[client] Shakes the shape visually.
pub fn multi_shape_shapes(&self) -> Vec<Shape>The shapes and joints of the multi-shape item this shape belongs to.
pub fn is_pipe(&self) -> boolTrue for pipe parts.
pub fn pipe_offsets(&self, direction: Option<i32>) -> Vec<Vec3>Pipe connection offsets, optionally for one direction only.
pub fn piped_neighbours(&self) -> Vec<Shape>[server] Pipes connected to this one.
pub fn output_container_index(&self) -> i32The output container index from the shapeset, for pipe graphs.
pub fn destroy(&self, attack_level: i32)[server] Destroys the shape with an attack level.
pub fn destroy_block(&self, local_position: Vec3, size: Vec3, d: &Destruction)[server] Removes the blocks of a block shape in the box at localPosition (a corner) of size.
pub fn replace(&self, uuid: Uuid)[server] Replaces the shape with another item, keeping its position.
pub fn body(&self) -> Bodypub fn interactable(&self) -> Interactablepub fn joints(&self, only_child_joints: bool) -> Vec<Joint>pub fn apply_impulse(&self, impulse: Vec3, world_space: bool, offset: Vec3)pub fn multi_shape_joints(&self) -> Vec<Joint>pub fn create_joint(&self, uuid: Uuid, local_position: Vec3, direction: Vec3) -> JointImplements Clone, Codec, Debug, Default, Display, FromLua, IntoLua, Object, PartialEq
object!(pub Body = "Body" )A rigid body: shapes connected without joints (Lua Body).
Methods
pub fn local_aabb(&self) -> AabbBounding box in body-local coordinates.
pub fn world_aabb(&self) -> AabbBounding box in world coordinates.
pub fn new(v: Value) -> SelfWraps a Lua value.
pub fn value(&self) -> &ValueThe wrapped Lua value.
pub fn is_nil(&self) -> boolTrue for nil.
pub fn exists(&self) -> boolTrue when the object still exists in the game (sm.exists).
pub fn id(&self) -> i32The body's id.
pub fn creation_id(&self) -> i32[server] The id of the creation (bodies connected by joints) it belongs to.
pub fn world_position(&self) -> Vec3Position of the body's origin.
pub fn center_of_mass(&self) -> Vec3Center of mass in world space.
pub fn velocity(&self) -> Vec3Linear / angular velocity.
pub fn angular_velocity(&self) -> Vec3pub fn mass(&self) -> f64Mass in kilograms.
pub fn shapes(&self) -> Vec<Shape>The body's shapes, interactables and joints.
pub fn creation_bodies(&self) -> Vec<Body>The bodies, shapes and joints of the whole creation.
pub fn creation_shapes(&self) -> Vec<Shape>pub fn shape_count(&self) -> i32Number of shapes.
pub fn shape(&self, index: i32) -> ShapeShape by index.
pub fn shapes_by_uuid(&self, uuid: Uuid) -> Vec<Shape>Shapes of one item type.
pub fn has_changed(&self, tick: i32) -> boolTrue if the body changed after tick (compare with game::currentTick()).
pub fn is_ghost(&self) -> boolTrue for a ghost (non-colliding) body.
pub fn is_on_virtual_lift(&self) -> boolTrue when held by a virtual lift.
pub fn is_connectable(&self) -> boolPermission flags: whether the body can be connected to, lifted, or made dynamic.
pub fn is_liftable(&self) -> boolpub fn is_convertible_to_dynamic(&self) -> boolpub fn set_connectable(&self, v: bool)[server] Sets those permission flags.
pub fn set_liftable(&self, v: bool)pub fn set_convertible_to_dynamic(&self, v: bool)pub fn is_static(&self) -> boolTrue if the body is static / dynamic.
pub fn is_dynamic(&self) -> boolpub fn is_on_lift(&self) -> boolTrue when on a lift.
pub fn is_buildable(&self) -> boolPermission flags: building, destruction, erasing, painting and use.
pub fn is_destructable(&self) -> boolpub fn is_erasable(&self) -> boolpub fn is_paintable(&self) -> boolpub fn is_usable(&self) -> boolpub fn set_buildable(&self, v: bool)[server] Sets those permission flags.
pub fn set_destructable(&self, v: bool)pub fn set_erasable(&self, v: bool)pub fn set_paintable(&self, v: bool)pub fn set_usable(&self, v: bool)pub fn transform_point(&self, world_point: Vec3) -> Vec3World point to body-local.
pub fn transform_local_point(&self, local_point: Vec3) -> Vec3Body-local point to world.
pub fn transform_world_point(&self, world_point: Vec3) -> Vec3World space to the body's local space.
pub fn create_block(&self, uuid: Uuid, size: Vec3, local_position: Vec3, force_accept: bool) -> Shape[server] Adds a block. forceAccept skips the overlap check.
pub fn create_part(&self, uuid: Uuid, local_position: Vec3, z_axis: Vec3, x_axis: Vec3, force_accept: bool) -> Shape[server] Adds a part oriented by its z and x axes.
pub fn create_wedge(&self, uuid: Uuid, size: Vec3, local_position: Vec3, z_axis: Vec3, x_axis: Vec3, force_accept: bool)[server] Adds a wedge.
pub fn destroy_creation(&self)[server] Destroys the whole creation.
pub fn world(&self) -> Worldpub fn interactables(&self) -> Vec<Interactable>pub fn joints(&self) -> Vec<Joint>pub fn seated_characters(&self) -> Vec<Character>pub fn apply_impulse(&self, impulse: Vec3, world_space: bool, offset: Vec3)pub fn apply_torque(&self, torque: Vec3, world_space: bool)pub fn creation_joints(&self) -> Vec<Joint>pub fn lift(&self) -> LiftImplements Clone, Codec, Debug, Default, Display, FromLua, IntoLua, Object, PartialEq
Interactable
Section titled "Interactable"object!(pub Interactable = "Interactable" )The scripted, connectable side of a part (Lua Interactable).
Methods
pub fn on_damage_destruction(&self, f: impl FnMut() + 'static)[server] Runs when the interactable is destroyed by damage.
pub fn steering_joint(&self, joint: &Joint) -> SteeringJointReads a bearing's steering settings.
pub fn new(v: Value) -> SelfWraps a Lua value.
pub fn value(&self) -> &ValueThe wrapped Lua value.
pub fn is_nil(&self) -> boolTrue for nil.
pub fn exists(&self) -> boolTrue when the object still exists in the game (sm.exists).
pub fn id(&self) -> i32The interactable's id.
pub fn shape(&self) -> ShapeThe shape and body it belongs to.
pub fn body(&self) -> Bodypub fn kind(&self) -> StringThe interactable type, e.g. "engine".
pub fn is_active(&self) -> boolTrue when active (on).
pub fn set_active(&self, on: bool)[server] Turns the interactable on or off.
pub fn power(&self) -> f64The output power value.
pub fn set_power(&self, p: f64)[server] Sets the output power.
pub fn parents(&self, filter: Option<Connection>) -> Vec<Interactable>Interactables connected as inputs / outputs, optionally of one connection type.
pub fn children(&self, filter: Option<Connection>) -> Vec<Interactable>pub fn single_parent(&self) -> InteractableThe only parent, or empty.
pub fn connect(&self, child: &Interactable) -> bool[server] Connects an output to child.
pub fn disconnect(&self, child: &Interactable) -> bool[server] Removes a connection to child.
pub fn public_data(&self) -> Value[server] Data other scripts can read.
pub fn set_public_data(&self, t: &Value)[server] Sets data other scripts can read.
pub fn has_seat(&self) -> boolTrue if the part has a seat.
pub fn set_uv_frame_index(&self, index: i32)[client] Visual state: UV frame, glow, animations and sub-mesh visibility.
pub fn set_glow_multiplier(&self, v: f64)pub fn set_anim_enabled(&self, name: &str, on: bool)pub fn set_anim_progress(&self, name: &str, progress: f64)pub fn set_sub_mesh_visible(&self, name: &str, visible: bool)pub fn remove_container(&self, index: i32)[server] Removes a container.
pub fn max_parent_count(&self) -> i32How many parents / children may connect.
pub fn max_child_count(&self) -> i32pub fn input_type(&self) -> ConnectionThe connection types accepted as input / produced as output.
pub fn output_type(&self) -> Connectionpub fn has_output_type(&self, flags: Connection) -> boolTrue if the output includes all of flags.
pub fn connection_color(&self) -> ColorConnection colors (normal / highlighted).
pub fn connection_highlight_color(&self) -> Colorpub fn has_changed(&self, tick: i32) -> boolTrue if the interactable had updates after tick.
pub fn client_public_data(&self) -> Value[client] Data other client scripts can read.
pub fn set_client_public_data(&self, t: &Value)[client] Sets data other client scripts can read.
pub fn set_params(&self, data: &Value)Params for an interactable created from a script.
pub fn carry_data(&self) -> Value[server] Data kept when the part is carried.
pub fn set_carry_data(&self, data: &Value)[server] Sets data kept when the part is carried.
pub fn seat_interactables(&self) -> Vec<Interactable>Interactables the seat controls (the hotbar of a seat).
pub fn press_seat_interactable(&self, index: i32) -> boolPresses / releases a seat hotbar slot.
pub fn release_seat_interactable(&self, index: i32) -> boolpub fn has_steering(&self) -> boolTrue for a driver's seat with steering.
pub fn steering_angle(&self) -> f64Steering input: A = -1, D = 1.
pub fn steering_power(&self) -> f64Throttle input: W = 1, S = -1.
pub fn steering_sprint(&self) -> boolTrue while sprinting in the seat.
pub fn set_steering_flag(&self, flags: i32)Sets / clears steering flags.
pub fn unset_steering_flag(&self, flags: i32)pub fn set_gyro_direction(&self, direction: Vec3)[client] Gyro / turret seats: aim direction, force and maximum speed.
pub fn set_gyro_force(&self, force: f64)pub fn set_gyro_max_speed(&self, speed: f64)pub fn set_light_override_color(&self, c: Color)[server] Overrides / restores the light color.
pub fn clear_light_override_color(&self)pub fn glow_multiplier(&self) -> f64The current glow multiplier.
pub fn uv_frame_index(&self) -> i32[client] The current UV frame.
pub fn pose_weight(&self, index: i32) -> f64[client] Reads / writes an animation pose weight.
pub fn set_pose_weight(&self, index: i32, weight: f64)pub fn has_anim(&self, name: &str) -> bool[client] True if the animation exists.
pub fn anim_duration(&self, name: &str) -> f64[client] An animation's length in seconds.
pub fn is_anim_looping(&self, name: &str) -> bool[client] True if an animation loops.
pub fn local_bone_position(&self, bone: &str) -> Vec3A bone's position, local / in the world.
pub fn world_bone_position(&self, bone: &str) -> Vec3pub fn seat_character(&self) -> Characterpub fn container(&self, index: i32) -> Containerpub fn add_container(&self, index: i32, size: i32, stack_size: Option<i32>) -> Containerpub fn joints(&self) -> Vec<Joint>pub fn bearings(&self) -> Vec<Joint>pub fn pistons(&self) -> Vec<Joint>pub fn connect_to_joint(&self, child: &Joint)pub fn joint_custom_data(&self, joint: &Joint) -> Valuepub fn set_joint_custom_data(&self, joint: &Joint, data: &Value)pub fn set_seat_character(&self, character: &Character)pub fn set_steering_joint(&self, joint: &Joint, s: &SteeringJoint)pub fn steering_joint_left_angle_limit(&self, j: &Joint) -> f64pub fn steering_joint_right_angle_limit(&self, j: &Joint) -> f64pub fn steering_joint_left_angle_speed(&self, j: &Joint) -> f64pub fn steering_joint_right_angle_speed(&self, j: &Joint) -> f64pub fn steering_joint_unlocked(&self, j: &Joint) -> boolpub fn set_steering_joint_left_angle_limit(&self, j: &Joint, v: f64)pub fn set_steering_joint_right_angle_limit(&self, j: &Joint, v: f64)pub fn set_steering_joint_left_angle_speed(&self, j: &Joint, v: f64)pub fn set_steering_joint_right_angle_speed(&self, j: &Joint, v: f64)pub fn set_steering_joint_unlocked(&self, j: &Joint, unlocked: bool)Implements Clone, Codec, Debug, Default, Display, FromLua, IntoLua, Object, PartialEq
object!(pub Joint = "Joint" )A joint: bearing, piston, spring or similar (Lua Joint).
Methods
pub fn sticky(&self) -> StickyThe sticky directions.
pub fn new(v: Value) -> SelfWraps a Lua value.
pub fn value(&self) -> &ValueThe wrapped Lua value.
pub fn is_nil(&self) -> boolTrue for nil.
pub fn exists(&self) -> boolTrue when the object still exists in the game (sm.exists).
pub fn id(&self) -> i32The joint's id.
pub fn kind(&self) -> StringThe joint type, e.g. "bearing" or "piston".
pub fn shape_a(&self) -> ShapeThe shape the joint is placed on.
pub fn shape_b(&self) -> ShapeThe shape on the joint's far side; empty when nothing is attached.
pub fn uuid(&self) -> UuidThe joint's item uuid.
pub fn world_position(&self) -> Vec3Position and rotation, in the world / on the body.
pub fn world_rotation(&self) -> Quatpub fn local_position(&self) -> Vec3pub fn local_rotation(&self) -> Quatpub fn x_axis(&self) -> Vec3The joint's local axes in world space.
pub fn y_axis(&self) -> Vec3pub fn z_axis(&self) -> Vec3pub fn bounding_box(&self) -> Vec3Size in blocks.
pub fn color(&self) -> ColorPaint color.
pub fn set_color(&self, c: Color)[server] Paints the joint.
pub fn multi_shape_shapes(&self) -> Vec<Shape>The shapes and joints of its multi-shape item.
pub fn multi_shape_joints(&self) -> Vec<Joint>pub fn angle(&self) -> f64A bearing's angle in radians and angular speed.
pub fn angular_velocity(&self) -> f64pub fn angular_velocity_vector(&self) -> Vec3Angular velocity as a vector.
pub fn applied_impulse(&self) -> f64The impulse the motor applied last tick.
pub fn bearing_enabled(&self) -> boolTrue if the bearing turns freely.
pub fn length(&self) -> f64A piston's current length.
pub fn is_reversed(&self) -> boolTrue if the joint is reversed.
pub fn create_block(&self, uuid: Uuid, size: Vec3, local_position: Vec3, force_create: bool)[server] Adds a block / part on the joint's far side.
pub fn create_part(&self, uuid: Uuid, local_position: Vec3, z_axis: Vec3, x_axis: Vec3, force_create: bool)pub fn set_motor_velocity(&self, velocity: f64, max_impulse: f64)Bearings: spins at velocity with up to maxImpulse.
pub fn set_target_angle(&self, angle: f64, velocity: f64, max_impulse: f64)Bearings: turns to angle.
pub fn set_target_length(&self, length: f64, velocity: f64, max_impulse: f64)[server] Pistons: extends to length.
Implements Clone, Codec, Debug, Default, Display, FromLua, IntoLua, Object, PartialEq
Character
Section titled "Character"object!(pub Character = "Character" )A character: a player's body or a creature (Lua Character).
Methods
pub fn active_animations(&self) -> Vec<ActiveAnimation>The animations playing now.
pub fn animation_info(&self, name: &str) -> AnimationInfoInformation about an animation.
pub fn on_animation(&self, name: &str, time: f64, f: impl FnMut() + 'static)Calls f when animation name reaches time.
pub fn new(v: Value) -> SelfWraps a Lua value.
pub fn value(&self) -> &ValueThe wrapped Lua value.
pub fn is_nil(&self) -> boolTrue for nil.
pub fn exists(&self) -> boolTrue when the object still exists in the game (sm.exists).
pub fn id(&self) -> i32The character's id.
pub fn is_player(&self) -> boolTrue for a player's character.
pub fn world_position(&self) -> Vec3Position in the world.
pub fn set_world_position(&self, p: Vec3)[server] Teleports the character.
pub fn velocity(&self) -> Vec3Velocity.
pub fn direction(&self) -> Vec3Look direction.
pub fn mass(&self) -> f64Mass, height and radius.
pub fn height(&self) -> f64pub fn radius(&self) -> f64pub fn color(&self) -> ColorColor.
pub fn set_color(&self, c: Color)[server] Paints the character.
pub fn is_on_ground(&self) -> boolMovement state.
pub fn is_crouching(&self) -> boolpub fn is_sprinting(&self) -> boolpub fn is_swimming(&self) -> boolpub fn is_seated(&self) -> boolpub fn is_tumbling(&self) -> boolpub fn is_downed(&self) -> boolpub fn set_tumbling(&self, v: bool)[server] Knocks the character over / lets it get up.
pub fn set_downed(&self, v: bool)[server] Downs the character or revives it.
pub fn set_movement_speed_fraction(&self, f: f64)Scales movement speed (1 is normal).
pub fn set_name_tag(&self, name: &str, color: Option<Color>)Shows a name tag above the character.
pub fn character_type(&self) -> UuidThe character type's uuid.
pub fn smooth_view_direction(&self) -> Vec3The look direction, smoothed.
pub fn surface_normal(&self) -> Vec3The normal of the surface the character stands on.
pub fn is_default_color(&self) -> boolTrue if the character has its default color.
pub fn is_moving(&self) -> boolMore movement state.
pub fn is_aiming(&self) -> boolpub fn is_climbing(&self) -> boolpub fn is_ladder_climbing(&self) -> boolpub fn is_diving(&self) -> boolpub fn is_flying(&self) -> boolpub fn is_hovering(&self) -> boolpub fn can_swim(&self) -> boolTrue if the character type can swim.
pub fn set_swimming(&self, v: bool)[server] Forces a movement state.
pub fn set_diving(&self, v: bool)pub fn set_climbing(&self, v: bool)pub fn set_flying(&self, v: bool)pub fn set_hovering(&self, v: bool)pub fn immovable(&self) -> bool[server] Whether the character can be pushed.
pub fn set_immovable(&self, v: bool)[server] Makes the character immovable or movable.
pub fn move_speed(&self) -> f64Base walking and sprinting speeds.
pub fn sprint_speed(&self) -> f64pub fn current_movement_speed(&self) -> f64The current movement speed.
pub fn movement_speed_fraction(&self) -> f64The movement speed scale.
pub fn jump_speed_fraction(&self) -> f64Reads / writes the jump height scale.
pub fn set_jump_speed_fraction(&self, f: f64)pub fn movement_noise_radius(&self) -> f64How far the character's movement can be heard by AI.
pub fn set_movement_effects(&self, effect_set_path: &str)Sets the effect set used for footsteps and other movement sounds.
pub fn tumbling_world_position(&self) -> Vec3The tumbling (ragdoll) body's position, rotation, velocities and size.
pub fn tumbling_world_rotation(&self) -> Quatpub fn tumbling_linear_velocity(&self) -> Vec3pub fn tumbling_angular_velocity(&self) -> Vec3pub fn tumbling_extent(&self) -> Vec3pub fn apply_tumbling_impulse(&self, impulse: Vec3, offset: Option<Vec3>)Pushes the tumbling body.
pub fn set_allow_tumble_animations(&self, allow: bool)Whether tumbling plays animations.
pub fn public_data(&self) -> Value[server] Data other server scripts can read.
pub fn set_public_data(&self, t: &Value)[server] Sets data other server scripts can read.
pub fn client_public_data(&self) -> Value[client] Data other client scripts can read.
pub fn set_client_public_data(&self, t: &Value)[client] Sets data other client scripts can read.
pub fn tp_bone_position(&self, bone: &str) -> Vec3A bone's third person position / rotation.
pub fn tp_bone_rotation(&self, bone: &str) -> Quatpub fn update_animation(&self, name: &str, time: f64, weight: Option<f64>, additive: bool)Plays an animation at time with an optional blend weight.
pub fn has_active_override_animation(&self) -> boolTrue while an override animation plays.
pub fn set_movement_weights(&self, lower: f64, upper: f64)Blend weights of the lower and upper body movement animations.
pub fn remove_animation_callbacks(&self)Removes every onAnimation callback.
pub fn has_graphics(&self) -> boolTrue once the character's graphics are loaded.
pub fn is_visible(&self) -> boolVisibility.
pub fn set_visible(&self, visible: bool)pub fn add_renderable(&self, rend: &str)Adds / removes a renderable on the character.
pub fn remove_renderable(&self, rend: &str)pub fn override_renderables(&self, rends: &[String])Replaces the character's renderables.
pub fn glow_multiplier(&self) -> f64Reads / writes the glow multiplier.
pub fn set_glow_multiplier(&self, v: f64)pub fn set_up_direction(&self, up: Vec3)Sets which way is up for the character.
pub fn player(&self) -> Playerpub fn world(&self) -> Worldpub fn apply_impulse(&self, impulse: Vec3)pub fn locking_interactable(&self) -> Interactablepub fn set_locking_interactable(&self, i: &Interactable) -> boolpub fn locking_harvestable(&self) -> Harvestablepub fn set_locking_harvestable(&self, h: &Harvestable) -> boolpub fn unit(&self) -> UnitImplements Clone, Codec, Debug, Default, Display, FromLua, IntoLua, Object, PartialEq
Player
Section titled "Player"object!(pub Player = "Player" )A connected player (Lua Player).
Methods
pub fn new(v: Value) -> SelfWraps a Lua value.
pub fn value(&self) -> &ValueThe wrapped Lua value.
pub fn is_nil(&self) -> boolTrue for nil.
pub fn exists(&self) -> boolTrue when the object still exists in the game (sm.exists).
pub fn id(&self) -> i32The player's id.
pub fn name(&self) -> StringThe player's display name.
pub fn character(&self) -> CharacterThe player's current character.
pub fn is_male(&self) -> boolThe character's body type.
pub fn is_female(&self) -> boolpub fn public_data(&self) -> Value[server] Data other scripts can read.
pub fn set_public_data(&self, t: &Value)[server] Sets data other scripts can read.
pub fn client_public_data(&self) -> Value[client] Data other client scripts can read.
pub fn set_client_public_data(&self, t: &Value)[client] Sets data other client scripts can read.
pub fn is_active(&self) -> boolTrue until the player has left.
pub fn current_tool_uuid(&self) -> UuidThe uuid of the tool the player holds.
pub fn customization_uuid(&self, index: i32) -> Uuid[server] The uuid of customization slot index.
pub fn set_character(&self, c: &Character)[server] Gives the player a character.
pub fn send_character_event(&self, event: &str)[server] Fires client_onEvent on the player's character.
pub fn carry_color(&self) -> Color[server] The carried item's color.
pub fn carry_data(&self) -> Value[server] Data of the carried item.
pub fn set_carry_data(&self, t: &Value)[server] Sets the carried item's data.
pub fn place_lift(&self, creation: &[Body], position: Vec3, level: i32, rotation: i32)[server] Places the player's lift, carrying creation, at level with rotation (0..3).
pub fn remove_lift(&self)[server] Removes the player's lift.
pub fn inventory(&self) -> Containerpub fn hotbar(&self) -> Containerpub fn carry(&self) -> ContainerImplements Clone, Codec, Debug, Default, Display, FromLua, IntoLua, Object, PartialEq
Container
Section titled "Container"object!(pub Container = "Container" )An item container: inventory, chest, hotbar... (Lua Container).
Methods
pub fn item(&self, slot: i32) -> ItemThe item stack in slot.
pub fn can_collect_all(&self, items: &[Item]) -> boolTrue if the container has room for all of items.
pub fn first_item(&self) -> ItemThe first non-empty stack.
pub fn on_transaction(&self, f: impl FnMut() + 'static)[server] Runs after every transaction that changed this container.
pub fn new(v: Value) -> SelfWraps a Lua value.
pub fn value(&self) -> &ValueThe wrapped Lua value.
pub fn is_nil(&self) -> boolTrue for nil.
pub fn exists(&self) -> boolTrue when the object still exists in the game (sm.exists).
pub fn size(&self) -> i32Number of slots.
pub fn is_empty(&self) -> boolTrue if every / no slot is free.
pub fn is_full(&self) -> boolpub fn can_collect(&self, item: Uuid, quantity: i32) -> boolTrue if quantity of item fit / can be taken.
pub fn can_spend(&self, item: Uuid, quantity: i32) -> boolpub fn count(&self, item: Uuid) -> i32Total quantity of an item.
pub fn max_stack_size(&self) -> i32Largest stack per slot.
pub fn unique_items(&self) -> Vec<Uuid>Each item type present, once.
pub fn item_uuids(&self) -> Vec<Uuid>Every slot's uuid / quantity, in slot order.
pub fn quantities(&self) -> Vec<i32>pub fn revision(&self) -> i32Network revision, bumped on every change.
pub fn has_changed(&self, tick: i32) -> bool[server] True if the container changed after tick.
pub fn allow_collect(&self) -> bool[server] Whether items can be put in / taken out.
pub fn allow_spend(&self) -> boolpub fn move_all_to_carry(&self, player: &Player, color: Color)[server] Moves everything into player's carry container, painted color.
pub fn collect(&self, item: Uuid, quantity: i32, must_collect_all: bool) -> i32[server] Adds / removes items; returns how many were moved. Use inside container::transaction.
pub fn spend(&self, item: Uuid, quantity: i32, must_spend_all: bool) -> i32pub fn collect_to_slot(&self, slot: i32, item: Uuid, quantity: i32, must_collect_all: bool) -> i32[server] Adds to / takes from one slot.
pub fn spend_from_slot(&self, slot: i32, item: Uuid, quantity: i32, must_spend_all: bool) -> i32pub fn swap(&self, other: &Container, from_slot: i32, to_slot: i32) -> bool[server] Swaps slots with another container.
pub fn move_all_to(&self, other: &Container)[server] Moves everything to another container.
pub fn set_item(&self, slot: i32, item: Uuid, quantity: i32) -> bool[server] Direct edits, outside transactions: set a slot, clear, resize, and allow collecting / spending.
pub fn clear(&self)pub fn resize(&self, size: i32, stack_size: Option<i32>)pub fn set_allow_collect(&self, allow: bool)pub fn set_allow_spend(&self, allow: bool)pub fn set_filters(&self, allowed: &[Uuid])[server] Only these items may be put in (empty: anything).
Implements Clone, Codec, Debug, Default, Display, FromLua, IntoLua, Object, PartialEq
object!(pub World = "World" )A world: terrain, cells and everything in them (Lua World).
Methods
pub fn cell_bounds(&self) -> CellBoundsReads the world's cell bounds.
pub fn load_cell(&self, x: i32, y: i32, player: &Player, on_loaded: Option<CellCallback>)[server] Loads a cell for player (nil for none); on_loaded(x, y) runs when it's ready.
pub fn load_cell_with_handle(&self, x: i32, y: i32, on_loaded: Option<CellCallback>) -> LoadCellHandle[server] Loads a cell and keeps it loaded while the handle lives.
pub fn load_nav_mesh_with_handle( &self, x: i32, y: i32, on_loaded: Option<CellCallback>, ) -> LoadCellHandle[server] Loads a cell's navigation mesh and keeps it loaded while the handle lives.
pub fn reload_cell(&self, x: i32, y: i32, on_done: Option<ReloadCallback>)[server] Reloads a cell; on_done(x, y, ok) runs when it's done.
pub fn dominant_material_in_sphere(&self, position: Vec3, radius: f64) -> VoxelMaterialThe most common voxel material in a sphere / capsule.
pub fn dominant_material_in_capsule(&self, position: Vec3, radius: f64, height: f64) -> VoxelMaterialpub fn voxel_material_at(&self, world_position: Vec3) -> VoxelMaterialThe voxel material at a world position.
pub fn weighted_voxel_density_at(&self, point: Vec3) -> WeightedDensityReads the interpolated voxel density at a point.
pub fn sphere_voxel_density_subtraction( &self, position: Vec3, radius: f64, filter: Option<i32>, strength: Option<f64>, on_done: Option<VoxelCallback>, )[server] Removes voxel density in a sphere; on_done(data) gets the engine's result.
pub fn voxel_density_subtraction( &self, position: Vec3, direction: Vec3, radius: f64, target_density: i32, filter: Option<i32>, destruction_effect: bool, on_done: Option<VoxelCallback>, )[server] Removes voxel density along direction down to target_density.
pub fn voxel_density_subtraction_per_material( &self, position: Vec3, direction: Vec3, radius: f64, target_densities: &[i32], filter: Option<i32>, destruction_effect: bool, on_done: Option<VoxelCallback>, )Like voxel_density_subtraction, with a target density per material.
pub fn new(v: Value) -> SelfWraps a Lua value.
pub fn value(&self) -> &ValueThe wrapped Lua value.
pub fn is_nil(&self) -> boolTrue for nil.
pub fn exists(&self) -> boolTrue when the object still exists in the game (sm.exists).
pub fn id(&self) -> i32The world's id.
pub fn is_indoor(&self) -> boolTrue for an indoor world.
pub fn destroy(&self)[server] Destroys the world.
pub fn is_cell_in_bounds(&self, x: i32, y: i32) -> boolTrue if the cell is inside the bounds.
pub fn is_cell_loaded_server(&self, x: i32, y: i32) -> bool[server] True if the cell is loaded on the server.
pub fn is_cell_loaded_client(&self, x: i32, y: i32) -> bool[client] True if the cell is loaded on this client.
pub fn set_terrain_script_data(&self, data: &Value)Data for the terrain generation script (Create's data).
pub fn zone_id(&self, position: Vec3) -> ValueThe zone id at a position (nil if none).
pub fn set_light_color_override(&self, c: Color)[server] Overrides every light controller's color in the world.
pub fn clear_light_color_override(&self)[server] Removes the light color override.
pub fn is_voxel_terrain_point_clear(&self, reference_position: Vec3, test_position: Vec3) -> boolTrue if testPosition is free of voxel terrain, as seen from referencePosition.
pub fn sphere_voxel_density_addition(&self, position: Vec3, radius: f64, material: i32, player: &Player)[server] Adds voxels in a sphere.
pub fn voxel_density_addition(&self, position: Vec3, surface_normal: Vec3, max_distance: f64, target_density: i32, material: i32, filter: Option<i32>, player: &Player)[server] Adds voxels along surfaceNormal up to maxDistance.
pub fn set_mining_config(&self, config: &Value)[server] Mining loot config (see WorldClass::server_onMining).
Implements Clone, Codec, Debug, Default, Display, FromLua, IntoLua, Object, PartialEq
Harvestable
Section titled "Harvestable"object!(pub Harvestable = "Harvestable" )A tree, rock, plant or kinematic object (Lua Harvestable).
Methods
pub fn aabb(&self) -> AabbThe bounding box in world / local coordinates.
pub fn local_aabb(&self) -> Aabbpub fn new(v: Value) -> SelfWraps a Lua value.
pub fn value(&self) -> &ValueThe wrapped Lua value.
pub fn is_nil(&self) -> boolTrue for nil.
pub fn exists(&self) -> boolTrue when the object still exists in the game (sm.exists).
pub fn id(&self) -> i32The harvestable's id.
pub fn uuid(&self) -> UuidIts item uuid, name and type.
pub fn name(&self) -> Stringpub fn kind(&self) -> Stringpub fn position(&self) -> Vec3Position, rotation and scale.
pub fn rotation(&self) -> Quatpub fn scale(&self) -> Vec3pub fn color(&self) -> ColorColor.
pub fn set_color(&self, c: Color)Paints the harvestable.
pub fn destroy(&self)[server] Destroys the harvestable.
pub fn world(&self) -> WorldThe world it's in.
pub fn set_position(&self, p: Vec3)Moves / rotates a kinematic harvestable.
pub fn set_rotation(&self, q: Quat)pub fn velocity(&self) -> Vec3Velocity and angular velocity.
pub fn angular_velocity(&self) -> Vec3pub fn mass(&self) -> f64Mass in kilograms.
pub fn material(&self) -> StringThe physics material name and id.
pub fn material_id(&self) -> i32pub fn transform_point(&self, world_point: Vec3) -> Vec3World point to local / local point to world / world direction to local.
pub fn transform_local_point(&self, local_point: Vec3) -> Vec3pub fn transform_direction(&self, world_dir: Vec3) -> Vec3pub fn is_kinematic(&self) -> boolTrue for a kinematic (scripted, movable) harvestable.
pub fn is_cell_kinematic(&self) -> boolTrue for a kinematic placed by a cell (vs. created from a script).
pub fn initial_hash(&self) -> f64Identifies a kinematic across reloads (harvestables::byInitialHash).
pub fn data(&self) -> ValueThe script data from the harvestable's definition.
pub fn set_params(&self, data: &Value)[server] Sets the params of a harvestable created from a script.
pub fn public_data(&self) -> Value[server] Data other scripts can read.
pub fn set_public_data(&self, t: &Value)[server] Sets data other scripts can read.
pub fn client_public_data(&self) -> Value[client] Data other client scripts can read.
pub fn set_client_public_data(&self, t: &Value)[client] Sets data other client scripts can read.
pub fn has_seat(&self) -> boolSeats (kinematics with a seat component): whether there is one, who sits in it, and seating a character.
pub fn apply_shake_impulse(&self, shake: f64)[client] Shakes the harvestable visually.
pub fn uv_frame_index(&self) -> i32[client] Reads / writes the UV frame.
pub fn set_uv_frame_index(&self, index: i32)pub fn pose_weight(&self, index: i32) -> f64[client] Reads / writes an animation pose weight.
pub fn set_pose_weight(&self, index: i32, weight: f64)pub fn set_sub_mesh_visible(&self, name: &str, visible: bool)[client] Shows or hides one / every sub-mesh.
pub fn set_all_sub_mesh_visible(&self, visible: bool)pub fn seat_character(&self) -> Characterpub fn set_seat_character(&self, c: &Character)Implements Clone, Codec, Debug, Default, Display, FromLua, IntoLua, Object, PartialEq
Network
Section titled "Network"object!(pub Network = "Network" )A script's network channel between its server and client sides (self.network).
Methods and constants
pub const PACKET_LIMIT: usize = NETWORK_PACKET_LIMITThe largest single network send (NETWORK_PACKET_LIMIT).
pub fn send_to_server(&self, method: &str, data: impl IntoLua)[client] Calls method(data, sender) on the server side. Pass () for no data.
pub fn send_to_clients(&self, method: &str, data: impl IntoLua)[server] Calls method(data) on every client.
pub fn send_to_client(&self, player: &Player, method: &str, data: impl IntoLua)[server] Calls method(data) on one player's client.
pub fn set_client_data(&self, data: impl IntoLua, channel: i32)[server] Sets data synced to client_on_client_data_update on every client, including players who join later. One value per channel (1 or 2).
pub fn new(v: Value) -> SelfWraps a Lua value.
pub fn value(&self) -> &ValueThe wrapped Lua value.
pub fn is_nil(&self) -> boolTrue for nil.
pub fn exists(&self) -> boolTrue when the object still exists in the game (sm.exists).
Implements Clone, Codec, Debug, Default, Display, FromLua, IntoLua, Object, PartialEq
Effect
Section titled "Effect"object!(pub Effect = "Effect" )A visual or sound effect (Lua Effect).
Methods
pub fn set_parameter(&self, name: &str, value: impl IntoLua)Sets an effect parameter.
pub fn set_host(&self, host: &impl IntoLua, bone: &str)Attaches the effect to a host, optionally to a bone ("" for none).
pub fn camera_data(&self) -> CameraData[client] The camera the effect controls (camera effects).
pub fn new(v: Value) -> SelfWraps a Lua value.
pub fn value(&self) -> &ValueThe wrapped Lua value.
pub fn is_nil(&self) -> boolTrue for nil.
pub fn exists(&self) -> boolTrue when the object still exists in the game (sm.exists).
pub fn start(&self)Starts playing.
pub fn stop(&self)Stops, letting the effect finish / stops at once.
pub fn stop_immediate(&self)pub fn destroy(&self)Destroys the effect.
pub fn is_playing(&self) -> boolTrue while playing.
pub fn is_done(&self) -> boolTrue once finished.
pub fn set_position(&self, p: Vec3)Sets position, rotation, velocity and scale.
pub fn set_rotation(&self, q: Quat)pub fn set_velocity(&self, v: Vec3)pub fn set_scale(&self, s: Vec3)pub fn set_offset_position(&self, p: Vec3)Offset from the host.
pub fn set_offset_rotation(&self, q: Quat)pub fn set_auto_play(&self, on: bool)Whether the effect restarts by itself when done.
pub fn id(&self) -> i32The effect's id.
pub fn world_position(&self) -> Vec3[client] The effect's position in the world.
pub fn set_start_stop_distance(&self, start_distance: f64, stop_distance: f64)Starts when the camera is within startDistance, stops beyond stopDistance.
pub fn has_host(&self) -> bool[client] True if attached to a host.
pub fn detach(&self)[client] Detaches from the host.
pub fn set_detach_on_host_destroy(&self, detach: bool)[client] Whether to detach instead of being destroyed with the host.
pub fn set_host_axis_ignore(&self, axis: i32)[client] A rotation axis (sm.effect.axis...) that hosted effects ignore.
pub fn set_world(&self, w: &World)[client] The world the effect plays in.
pub fn set_world_any(&self)[client] Plays in every world, for global sounds.
pub fn set_time_of_day(&self, enabled: bool, start_time: f64, end_time: f64, inverse: bool)[client] Only active between startTime and endTime (0..1 time of day), or outside it if inverse.
pub fn is_break_sustaining(&self) -> bool[client] Sustained sounds: whether the sound is finishing, and letting it finish before it's destroyed.
pub fn stop_break_sustain(&self)pub fn has_active_camera(&self) -> bool[client] True while the effect controls the camera.
pub fn bind_event_client_callback(&self, params: &Value, reference: &Value)[client] Effect event callbacks: reference is the script table that receives them
(default: the running script), params is passed through.
pub fn bind_event_server_callback(&self, params: &Value, reference: &Value)pub fn clear_client_event_callback(&self)Removes the client / server event callbacks.
pub fn clear_server_event_callback(&self)Implements Clone, Codec, Debug, Default, Display, FromLua, IntoLua, Object, PartialEq
object!(pub Tool = "Tool" )A tool a player holds (Lua Tool).
Methods
pub fn animation_info(&self, name: &str) -> AnimationInfoInformation about a third / first person animation.
pub fn fp_animation_info(&self, name: &str) -> AnimationInfopub fn camera_weights(&self) -> CameraWeights[client] Current weights of the tool's camera settings (update_camera / update_fp_camera).
pub fn new(v: Value) -> SelfWraps a Lua value.
pub fn value(&self) -> &ValueThe wrapped Lua value.
pub fn is_nil(&self) -> boolTrue for nil.
pub fn exists(&self) -> boolTrue when the object still exists in the game (sm.exists).
pub fn id(&self) -> i32The tool's id.
pub fn uuid(&self) -> UuidThe tool's item uuid.
pub fn owner(&self) -> PlayerThe player holding it.
pub fn is_local(&self) -> boolTrue on the owner's client.
pub fn is_equipped(&self) -> boolTrue while equipped.
pub fn is_in_first_person_view(&self) -> boolThe owner's view and movement state.
pub fn is_crouching(&self) -> boolpub fn is_sprinting(&self) -> boolpub fn is_on_ground(&self) -> boolpub fn position(&self) -> Vec3Position and aim direction of the tool.
pub fn direction(&self) -> Vec3pub fn smooth_direction(&self) -> Vec3Aim direction, smoothed.
pub fn movement_velocity(&self) -> Vec3The owner's movement velocity.
pub fn movement_speed_fraction(&self) -> f64The owner's movement speed scale.
pub fn set_fp_renderables(&self, rends: &[String])[client] Sets the first / third person renderables (paths to .rend files) and their colors.
pub fn set_tp_renderables(&self, rends: &[String])pub fn set_fp_color(&self, c: Color)pub fn set_tp_color(&self, c: Color)pub fn update_animation(&self, name: &str, time: f64, weight: Option<f64>)[client] Plays a third person animation; time is seconds into it.
pub fn update_fp_animation(&self, name: &str, time: f64, weight: Option<f64>, looping: bool)[client] Plays a first person animation.
pub fn set_movement_animation(&self, movement: &str, animation: &str)[client] Replaces a movement animation (e.g. "idle") with one of the tool's.
pub fn set_movement_slow_down(&self, slow_down: bool)[client] Slows the owner down while held.
pub fn set_block_sprint(&self, block: bool)[client] Prevents sprinting while held.
pub fn set_cross_hair_alpha(&self, alpha: f64)[client] Crosshair alpha, color, type and spread.
pub fn set_cross_hair_color(&self, c: Color)pub fn set_cross_hair_type(&self, kind: i32)pub fn set_dispersion_fraction(&self, dispersion: f64)pub fn update_camera(&self, distance: f64, fov: f64, offset: Vec3, weight: f64)[client] Blends the camera toward a tool-specific view (aiming, ...).
pub fn fp_bone_position(&self, bone: &str) -> Vec3[client] A bone's first / third person position.
pub fn tp_bone_position(&self, bone: &str) -> Vec3pub fn fp_bone_direction(&self, bone: &str, world_space: bool) -> Vec3[client] Bones: first-person local (or world) space, third-person world space.
pub fn fp_bone_rotation(&self, bone: &str, world_space: bool) -> Quatpub fn tp_bone_direction(&self, bone: &str) -> Vec3pub fn tp_bone_rotation(&self, bone: &str) -> Quatpub fn update_joint(&self, bone: &str, rotation: Vec3, weight: Option<f64>)[client] Rotates a bone of the animation skeleton.
pub fn update_movement_animation(&self, time: f64, weight: Option<f64>)[client] Advances the movement animation set with setMovementAnimation.
pub fn relative_move_direction(&self) -> Vec3[client] Movement direction relative to where the player looks.
pub fn update_fp_camera(&self, fov: f64, offset: Vec3, weight: f64, bobbing: f64)[client] Blends the first person camera toward a tool-specific view.
Implements Clone, Codec, Debug, Default, Display, FromLua, IntoLua, Object, PartialEq
LoadCellHandle
Section titled "LoadCellHandle"object!(pub LoadCellHandle = "LoadCellHandle" )The handle from World::loadCellWithHandle; the cell stays loaded until released.
Methods
pub fn new(v: Value) -> SelfWraps a Lua value.
pub fn value(&self) -> &ValueThe wrapped Lua value.
pub fn is_nil(&self) -> boolTrue for nil.
pub fn exists(&self) -> boolTrue when the object still exists in the game (sm.exists).
pub fn release(&self) -> bool[server] Releases the cell; returns true if it was held.
Implements Clone, Codec, Debug, Default, Display, FromLua, IntoLua, Object, PartialEq
object!(pub Lift = "Lift" )A player's or non-player lift (Lua Lift).
Methods
pub fn new(v: Value) -> SelfWraps a Lua value.
pub fn value(&self) -> &ValueThe wrapped Lua value.
pub fn is_nil(&self) -> boolTrue for nil.
pub fn exists(&self) -> boolTrue when the object still exists in the game (sm.exists).
pub fn id(&self) -> i32The lift's id.
pub fn level(&self) -> i32Its height level.
pub fn world_position(&self) -> Vec3Its position.
pub fn has_bodies(&self) -> boolTrue if it carries bodies.
pub fn destroy(&self)[server] Removes the lift.
Implements Clone, Codec, Debug, Default, Display, FromLua, IntoLua, Object, PartialEq
Portal
Section titled "Portal"object!(pub Portal = "Portal" )A two-opening portal between (or within) worlds. All [server].
Methods
pub fn new(v: Value) -> SelfWraps a Lua value.
pub fn value(&self) -> &ValueThe wrapped Lua value.
pub fn is_nil(&self) -> boolTrue for nil.
pub fn exists(&self) -> boolTrue when the object still exists in the game (sm.exists).
pub fn id(&self) -> i32The portal's id.
pub fn has_opening_a(&self) -> bool[server] True if opening A / B is placed.
pub fn has_opening_b(&self) -> boolpub fn set_opening_a(&self, position: Vec3, rotation: Quat, world: &World)[server] Places opening A / B.
pub fn set_opening_b(&self, position: Vec3, rotation: Quat, world: &World)pub fn position_a(&self) -> Vec3[server] Positions, rotations and worlds of the two openings.
pub fn position_b(&self) -> Vec3pub fn rotation_a(&self) -> Quatpub fn rotation_b(&self) -> Quatpub fn world_a(&self) -> Worldpub fn world_b(&self) -> Worldpub fn transfer_a_to_b(&self, filter: Option<i32>) -> bool[server] Moves what's in one opening to the other (filter: sm.areaTrigger.filter).
pub fn transfer_b_to_a(&self, filter: Option<i32>) -> boolpub fn set_a_marker_offset(&self, offset: Vec3)[server] Map markers: offsets, and whether each direction shows one.
pub fn set_b_marker_offset(&self, offset: Vec3)pub fn set_a_to_b_marker_allowed(&self, allowed: bool)pub fn set_b_to_a_marker_allowed(&self, allowed: bool)pub fn contents_a(&self) -> Vec<Target>pub fn contents_b(&self) -> Vec<Target>Implements Clone, Codec, Debug, Default, Display, FromLua, IntoLua, Object, PartialEq
Storage
Section titled "Storage"object!(pub Storage = "Storage" )Server-side save data of a script (ScriptClass::storage()). All [server].
Methods
pub fn save(&self, data: &impl IntoLua)[server] Saves data for the next time the object loads.
pub fn new(v: Value) -> SelfWraps a Lua value.
pub fn value(&self) -> &ValueThe wrapped Lua value.
pub fn is_nil(&self) -> boolTrue for nil.
pub fn exists(&self) -> boolTrue when the object still exists in the game (sm.exists).
pub fn load(&self) -> Value[server] The saved data, or nil.
Implements Clone, Codec, Debug, Default, Display, FromLua, IntoLua, Object, PartialEq
Target
Section titled "Target"object!(pub Target = "Target" )A value that may be one of several object types (a collision's "other", a projectile's shooter, ...). Test with is(), convert with to().
Methods
pub fn kind(&self) -> StringThe Lua type name: "Shape", "Character", "Harvestable", ..., or "nil".
pub fn is<T: Object>(&self) -> boolTrue if the target is a T.
pub fn to<T: Object>(&self) -> TThe target as a T.
pub fn new(v: Value) -> SelfWraps a Lua value.
pub fn value(&self) -> &ValueThe wrapped Lua value.
pub fn is_nil(&self) -> boolTrue for nil.
pub fn exists(&self) -> boolTrue when the object still exists in the game (sm.exists).
Implements Clone, Codec, Debug, Default, Display, FromLua, IntoLua, Object, PartialEq
object!(pub Unit = "Unit" )The AI driving a creature (Lua Unit). Most calls are [server].
Methods
pub fn new(v: Value) -> SelfWraps a Lua value.
pub fn value(&self) -> &ValueThe wrapped Lua value.
pub fn is_nil(&self) -> boolTrue for nil.
pub fn exists(&self) -> boolTrue when the object still exists in the game (sm.exists).
pub fn id(&self) -> i32[server] The unit's id.
pub fn character(&self) -> Character[server] The character it controls.
pub fn facing_direction(&self) -> Vec3[server] The current facing / movement direction.
pub fn movement_direction(&self) -> Vec3pub fn set_facing_direction(&self, d: Vec3)[server] Sets the direction to face / move in.
pub fn set_movement_direction(&self, d: Vec3)pub fn set_movement_type(&self, kind: &str)[server] Sets how to move: "stand", "walk", "sprint", "crouch", ...
pub fn set_wants_jump(&self, jump: bool)[server] Requests a jump / crouch.
pub fn set_wants_crouch(&self, crouch: bool)pub fn set_whisker_data(&self, count: i32, max_angle: f64, start_length: f64, end_length: f64)[server] Configures the obstacle-sensing rays used for movement.
pub fn set_hearing_data(&self, noise_scale: f64)[server] Scales how well the unit hears noise.
pub fn send_character_event(&self, event: &str)[server] Fires client_onEvent on the unit's character.
pub fn public_data(&self) -> Value[server] Data other scripts can read, and setting it.
pub fn set_public_data(&self, t: &Value)pub fn container(&self, index: i32) -> ContainerA container of the unit by index.
pub fn add_container(&self, index: i32, size: i32, stack_size: Option<i32>) -> Container[server] Adds a container of size slots.
pub fn remove_container(&self, index: i32)[server] Removes a container.
pub fn destroy(&self)[server] Destroys the unit.
pub fn create_state(&self, name: &str) -> AiStateImplements Clone, Codec, Debug, Default, Display, FromLua, IntoLua, Object, PartialEq
AiState
Section titled "AiState"object!(pub AiState = "AiState" )A built-in AI behaviour from Unit::createState. Drive it from server_onUnitUpdate. All [server].
Methods
pub fn is_done(&self) -> AiDone[server] Whether it's done, and why (e.g. "finished" / "failed").
pub fn new(v: Value) -> SelfWraps a Lua value.
pub fn value(&self) -> &ValueThe wrapped Lua value.
pub fn is_nil(&self) -> boolTrue for nil.
pub fn exists(&self) -> boolTrue when the object still exists in the game (sm.exists).
pub fn start(&self)[server] Starts / stops the behaviour.
pub fn stop(&self)pub fn on_fixed_update(&self, dt: f64)[server] Advances the behaviour; call from the matching unit callback.
pub fn on_unit_update(&self, dt: f64)pub fn facing_direction(&self) -> Vec3[server] What the state wants the unit to do; apply it with the Unit setters.
pub fn movement_direction(&self) -> Vec3pub fn movement_type(&self) -> Stringpub fn wants_jump(&self) -> boolpub fn wants_crouch(&self) -> boolImplements Clone, Codec, Debug, Default, Display, FromLua, IntoLua, Object, PartialEq
PathNode
Section titled "PathNode"object!(pub PathNode = "PathNode" )A navigation node for sm.pathfinder (pathNodes::create). All [server].
Methods
pub fn new(v: Value) -> SelfWraps a Lua value.
pub fn value(&self) -> &ValueThe wrapped Lua value.
pub fn is_nil(&self) -> boolTrue for nil.
pub fn exists(&self) -> boolTrue when the object still exists in the game (sm.exists).
pub fn position(&self) -> Vec3[server] The node's position.
pub fn connect(&self, to: &PathNode)[server] Links this node to another.
pub fn destroy(&self)[server] Removes the node.
Implements Clone, Codec, Debug, Default, Display, FromLua, IntoLua, Object, PartialEq
ScriptableObject
Section titled "ScriptableObject"object!(pub ScriptableObject = "ScriptableObject" )A scriptable object: a script with no body in the world (Lua ScriptableObject).
Methods
pub fn new(v: Value) -> SelfWraps a Lua value.
pub fn value(&self) -> &ValueThe wrapped Lua value.
pub fn is_nil(&self) -> boolTrue for nil.
pub fn exists(&self) -> boolTrue when the object still exists in the game (sm.exists).
pub fn id(&self) -> i32The object's id.
pub fn world(&self) -> WorldThe world it's in.
pub fn data(&self) -> ValueThe params it was created with.
pub fn public_data(&self) -> Value[server] Data other server scripts can read.
pub fn set_public_data(&self, t: &Value)[server] Sets data other server scripts can read.
pub fn client_public_data(&self) -> Value[client] Data other client scripts can read.
pub fn set_client_public_data(&self, t: &Value)[client] Sets data other client scripts can read.
pub fn destroy(&self)[server] Destroys the object.
Implements Clone, Codec, Debug, Default, Display, FromLua, IntoLua, Object, PartialEq
ClientScriptableObject
Section titled "ClientScriptableObject"object!(pub ClientScriptableObject = "ClientScriptableObject" )A scriptable object that only exists on one client (clientScriptableObjects::create). All [client].
Methods
pub fn new(v: Value) -> SelfWraps a Lua value.
pub fn value(&self) -> &ValueThe wrapped Lua value.
pub fn is_nil(&self) -> boolTrue for nil.
pub fn exists(&self) -> boolTrue when the object still exists in the game (sm.exists).
pub fn id(&self) -> i32The object's id.
pub fn world(&self) -> WorldThe world it's in.
pub fn data(&self) -> ValueThe params it was created with.
pub fn client_public_data(&self) -> ValueData other client scripts can read, and setting it.
pub fn set_client_public_data(&self, t: &Value)pub fn destroy(&self)Destroys the object.
Implements Clone, Codec, Debug, Default, Display, FromLua, IntoLua, Object, PartialEq
Functions
Section titled "Functions"pub fn is_server() -> boolTrue when running on the server side.
pub fn is_host() -> boolTrue when this game instance hosts the session.
Re-exports
Section titled "Re-exports"crate::script::CullingZoneTreecrate::script::InputBlockcrate::math::*core_hand::*ai_api::*client_api::*debug_draw_api::*gui_api::*item_api::*render_api::*terrain_api::*trigger_api::*util_api::*world_api::*
atl::sm::game
Section titled "atl::sm::game"Game state and settings (sm.game).
Functions in atl::sm::game
Section titled "Functions in atl::sm::game"pub fn server_tick() -> i32The server's tick counter.
pub fn current_tick() -> i32The current tick (40 per second).
pub fn time_of_day() -> f64The time of day, 0..1, where 0.5 is noon.
pub fn set_time_of_day(t: f64)[client] Sets the time of day.
pub fn difficulty() -> i32The game difficulty.
pub fn aggro_enabled() -> boolWhether creature aggression is enabled.
pub fn set_aggro_enabled(on: bool)[server] Enables or disables creature aggression.
pub fn ammo_consumption_enabled() -> boolWhether ammo consumption is enabled.
pub fn set_ammo_consumption_enabled(on: bool)[server] Enables or disables ammo consumption.
pub fn fuel_consumption_enabled() -> boolWhether fuel consumption is enabled.
pub fn set_fuel_consumption_enabled(on: bool)[server] Enables or disables fuel consumption.
pub fn restrictions_enabled() -> boolWhether build restrictions are enabled.
pub fn set_restrictions_enabled(on: bool)[server] Enables or disables build restrictions.
pub fn upgrade_enabled() -> boolWhether upgrades are enabled.
pub fn set_upgrade_enabled(on: bool)[server] Enables or disables upgrades.
pub fn recipes_enabled() -> boolWhether recipes are enabled.
pub fn set_recipes_enabled(on: bool)[server] Enables or disables recipes.
pub fn limited_inventory() -> boolWhether the limited inventory is enabled.
pub fn set_limited_inventory(on: bool)[server] Enables or disables the limited inventory.
pub fn setting_bool(name: &str) -> boolA game setting by name, as a boolean / number / string.
pub fn setting_number(name: &str) -> f64pub fn setting_string(name: &str) -> Stringpub fn kick(p: &Player)[server] Kicks a player.
pub fn ban(p: &Player)[server] Bans a player.
pub fn pause_saving(reason: &str, ticks: i32)[server] Holds off autosaving while something (named reason) is mid-change.
pub fn resume_saving(reason: &str)[server] Allows autosaving again.
pub fn exit_to_menu()Exits to the main menu.
pub fn exit_to_menu_with_end_credits()Exits to the main menu and plays the end credits.
pub fn load_watched_tutorials() -> Value[client] The tutorials the user has seen (a table you define).
pub fn save_watched_tutorials(watched: &Value)[client] Saves the tutorials the user has seen.
atl::sm::audio
Section titled "atl::sm::audio"Sounds (sm.audio).
Functions in atl::sm::audio
Section titled "Functions in atl::sm::audio"pub fn play(sound: &str, position: Option<Vec3>)Plays a sound, at a position or globally.
pub fn global_parameter(name: &str) -> f64[client] Reads / writes an FMOD global parameter.
pub fn set_global_parameter(name: &str, value: f64)atl::sm::effect
Section titled "atl::sm::effect"Effects (sm.effect).
Functions in atl::sm::effect
Section titled "Functions in atl::sm::effect"pub fn play(name: &str, position: Vec3, o: &PlayOptions)Plays a one-shot effect at a position.
pub fn create(name: &str) -> EffectCreates an effect you control (see Effect).
pub fn create_2d(name: &str) -> Effect[client] Creates a screen-space, first-person or sky effect.
pub fn create_first_person(name: &str) -> Effectpub fn create_sky(name: &str) -> Effectpub fn estimate_size(name: &str, parameters: &Value) -> f64[client] The radius of influence of name with these parameters.
Re-exports
Section titled "Re-exports"super::core_hand::effect_hand::*
atl::sm::physics
Section titled "atl::sm::physics"Physics queries and forces (sm.physics).
Functions in atl::sm::physics
Section titled "Functions in atl::sm::physics"pub fn shapes_in_sphere(center: Vec3, radius: f64, world: &World) -> Vec<Shape>Shapes overlapping a sphere / box.
pub fn shapes_in_box(center: Vec3, rotation: Quat, half_extents: Vec3, world: &World) -> Vec<Shape>pub fn sphere_has_contact(center: Vec3, radius: f64, include_terrain: bool, count_water: bool) -> boolWhether anything overlaps a sphere, and how many things.
pub fn sphere_contact_count(center: Vec3, radius: f64, include_terrain: bool, count_water: bool) -> i32pub fn capsule_has_contact(from: Vec3, to: Vec3, radius: f64, mask: Option<i32>) -> boolWhether anything overlaps a capsule, and how many things.
pub fn capsule_contact_count(from: Vec3, to: Vec3, radius: f64, mask: Option<i32>) -> i32pub fn is_point_in_liquid(point: Vec3) -> boolTrue if the point / sphere is in liquid.
pub fn is_sphere_in_liquid(center: Vec3, radius: f64) -> boolpub fn ground_material(point: Vec3) -> StringThe ground material at a point.
pub fn material_id(material: &str) -> i32A physics material's id by name.
pub fn gravity() -> f64[server] The gravity strength.
pub fn set_gravity(g: f64)[server] Sets the gravity strength.
Re-exports
Section titled "Re-exports"super::core_hand::physics_hand::*
atl::sm::players
Section titled "atl::sm::players"Players (sm.player).
Functions in atl::sm::players
Section titled "Functions in atl::sm::players"pub fn all() -> Vec<Player>Every connected player.
pub fn host() -> PlayerThe host player.
pub fn local() -> Player[client] This client's player.
pub fn place_lift(p: &Player, creation: &[Body], position: Vec3, level: i32, rotation: i32)[server] Same as Player::placeLift / removeLift.
pub fn remove_lift(p: &Player)atl::sm::shapes
Section titled "atl::sm::shapes"Creating and inspecting shapes (sm.shape).
Functions in atl::sm::shapes
Section titled "Functions in atl::sm::shapes"pub fn create_part(uuid: Uuid, position: Vec3, rotation: Quat, dynamic: bool) -> Shape[server] Creates a part.
pub fn create_block(uuid: Uuid, size: Vec3, position: Vec3, rotation: Quat, dynamic: bool) -> Shape[server] Creates a block of size.
pub fn create_wedge(uuid: Uuid, size: Vec3, position: Vec3, rotation: Quat, dynamic: bool, force_spawn: bool) -> Shape[server] Creates a wedge of size with its corner at position.
pub fn title(uuid: Uuid) -> StringAn item's display name / upper-case display name.
pub fn upper_case_title(uuid: Uuid) -> Stringpub fn type_color(uuid: Uuid) -> ColorThe color of the shape's type (block, part, ...) in the inventory.
pub fn is_harvest(uuid: Uuid) -> boolTrue for a harvested item / a stackable item.
pub fn is_stackable(uuid: Uuid) -> boolpub fn exists(uuid: Uuid) -> boolTrue if a shape with this uuid exists.
pub fn in_sphere(center: Vec3, radius: f64) -> Vec<Shape>Shapes within a sphere.
atl::sm::bodies
Section titled "atl::sm::bodies"Bodies (sm.body).
Functions in atl::sm::bodies
Section titled "Functions in atl::sm::bodies"pub fn create(position: Vec3, rotation: Quat, dynamic: bool) -> Body[server] Creates an empty body to build on (Body::createBlock / createPart).
pub fn all(world: &World) -> Vec<Body>Every body, optionally in one world.
pub fn creations(bodies: &[Body]) -> Vec<Vec<Body>>Groups bodies by creation.
atl::sm::json
Section titled "atl::sm::json"JSON (sm.json).
Functions in atl::sm::json
Section titled "Functions in atl::sm::json"pub fn parse(text: &str) -> ValueParses a JSON string.
pub fn stringify(v: &Value, pretty: bool) -> StringConverts a value to JSON.
pub fn open(path: &str) -> ValueReads a JSON file. Paths use the usual prefixes: "$CONTENT_DATA/...".
pub fn exists(path: &str) -> boolTrue if the file exists.
pub fn save(root: &Value, path: &str)Writes root (a table) as JSON. Only paths the game lets mods write, e.g. "$CONTENT_DATA/...".
atl::sm::units
Section titled "atl::sm::units"[server] AI units (sm.unit).
Functions in atl::sm::units
Section titled "Functions in atl::sm::units"pub fn create(uuid: Uuid, position: Vec3, yaw: f64, data: &Value) -> Unit[server] Creates a unit of the character type uuid, feet at position, facing yaw radians.
pub fn all() -> Vec<Unit>[server] Every unit.
pub fn in_range(world: &World, position: Vec3, range: f64) -> Vec<Unit>[server] Units within range of a position.
pub fn force_destroy(unit: &Unit)[server] Destroys the unit right away, skipping its death logic.
atl::sm::harvestables
Section titled "atl::sm::harvestables"[server] Harvestables (sm.harvestable).
Functions in atl::sm::harvestables
Section titled "Functions in atl::sm::harvestables"pub fn create(uuid: Uuid, position: Vec3, rotation: Quat) -> Harvestable[server] Creates a harvestable.
pub fn all() -> Vec<Harvestable>Every harvestable.
pub fn by_initial_hash(hash: f64) -> HarvestableThe kinematic with this Harvestable::initialHash() (empty if none).
atl::sm::characters
Section titled "atl::sm::characters"Characters (sm.character).
Functions in atl::sm::characters
Section titled "Functions in atl::sm::characters"pub fn create(player: &Player, world: &World, position: Vec3, yaw: f64, pitch: f64) -> Character[server] Creates a character for a player in a world.
atl::sm::scriptable_objects
Section titled "atl::sm::scriptable_objects"Scriptable objects (sm.scriptableObject).
Functions in atl::sm::scriptable_objects
Section titled "Functions in atl::sm::scriptable_objects"pub fn create(uuid: Uuid, params: &Value) -> ScriptableObject[server] Creates a scriptable object.
atl::sm::container
Section titled "atl::sm::container"Container transactions (sm.container).
Functions in atl::sm::container
Section titled "Functions in atl::sm::container"pub fn abort_transaction()[server] Cancels the running transaction.
Re-exports
Section titled "Re-exports"super::core_hand::container_hand::*
atl::sm::storage
Section titled "atl::sm::storage"Game-wide save data (sm.storage).
Functions in atl::sm::storage
Section titled "Functions in atl::sm::storage"pub fn load(key: &str) -> ValueLoads a value saved under a key.
pub fn load_terrain_data(world_id: i32) -> ValueThe terrain data a world's terrain script saved.
Re-exports
Section titled "Re-exports"super::core_hand::storage_hand::*