Skip to content

atl/sm

import "atl/sm"

The core Scrap Mechanic API: game object types (Shape, Body, Interactable, Character, Player, World, ...). The sm.* namespaces that operate on them are the atl/sm/... packages.

const PI = 3.14159265358979323846

Pi.

const DEG = PI / 180.0

Degrees to radians: 90 * sm.DEG.

const HalfSqrt2 = 0.70710678118654752440

Fixed 90 and 180 degree rotations (sm.quat.rotX90() and so on).

const NetworkPacketLimit = sys.NetworkPacketLimit

The most bytes one network send may carry (method name, data and the game's framing): a string payload costs its length + the method name's length + 14. Typed messages split themselves up; raw sends over it raise a Lua error, so check those against it.

func Sqrt(x float64) float64

Square root.

func Abs(x float64) float64

Absolute value.

func Sin(x float64) float64
func Cos(x float64) float64
func Tan(x float64) float64
func Asin(x float64) float64
func Acos(x float64) float64
func Atan2(y, x float64) float64
func Pow(x, y float64) float64

Trigonometry and pow, computed by Lua's math library.

func Floor(x float64) float64
func Ceil(x float64) float64

Rounds down / up to a whole number.

func Clamp(x, lo, hi float64) float64

x limited to the range lo..hi.

func Lerp(a, b, t float64) float64

Linear interpolation from a (t = 0) to b (t = 1).

func At[T any](r []atl.Value, i int) T

Result i of r converted to T, or T's zero value when there are fewer results.

func BindCallback(fn func(args atl.Value)) string

For engine APIs that take the name of a callback method: returns the name of a method on the running script's class that calls fn(args) (args.Index(1) is the first argument). Released with the script, like GUI callbacks.

func TargetIs[T Typed](t Target) bool

True if the value is a T.

func TargetAs[T any](t Target) T

The value as a T.

func IsServer() bool

True when running on the server side.

func IsHost() bool

True when this game instance hosts the session.

type GuiOptions struct {
DestroyOnClose bool
IsHud *bool
IsInteractive *bool
NeedsCursor *bool
HidesHotbar *bool
IsOverlapped *bool
BackgroundAlpha *float64
}

Options for GuiFromLayout. Unset fields keep the layout's own settings.

type Gui struct {
atl.Object
// contains filtered or unexported fields
}

A GUI (GuiInterface). Callbacks take funcs, and GUIs created through this type are destroyed with the script that created them, along with their callbacks. A tracked Gui stays valid across callbacks, so it can be stored in a field.

func NewGui(v atl.Value) Gui

Wraps an existing Lua GuiInterface without tracking it.

func GuiFromLayout(layout string, o GuiOptions) Gui

[client] Creates a GUI from a .layout file.

func GuiBuiltin(factory string, destroyOnClose bool) Gui

[client] Creates a built-in GUI by its sm.gui factory name, e.g. "createContainerGui".

func GuiWorldIcon(width, height int, layout *string, destroyOnClose bool) Gui

[client] Creates a GUI shown in the world (a marker or icon), optionally from a layout.

func AdoptGui(gui atl.Value, destroyOnClose bool) Gui

Takes over a GuiInterface created elsewhere, so its callbacks are cleaned up with this script.

Methods

func (g *Gui) Open()
func (g *Gui) Close()

Opens / closes the GUI.

func (g *Gui) IsActive() bool

True while open.

func (g *Gui) Destroy()

Destroys the GUI and frees its callbacks.

func (g *Gui) SetText(widget, text string)
func (g *Gui) SetVisible(widget string, visible bool)
func (g *Gui) SetImage(widget, imagePath string)
func (g *Gui) SetColor(widget string, c Color)

Sets a widget's text, visibility, image or color.

func (g *Gui) SetIconImage(widget string, item Uuid)
func (g *Gui) SetMeshPreview(widget string, item Uuid)

Shows an item's icon / 3D preview in a widget.

func (g *Gui) SetButtonState(widget string, pressed bool)
func (g *Gui) SetButtonEnabled(widget string, enabled bool)

Sets a button's pressed or enabled state.

func (g *Gui) SetWidgetState(widget string, state int)

Sets a widget's state.

func (g *Gui) SetFocus(widget string)

Gives a widget keyboard focus.

func (g *Gui) SetData(widget string, data atl.Value)

Passes data to a widget.

func (g *Gui) SetSliderData(slider string, rng, position int)
func (g *Gui) SetSliderPosition(slider string, position int)
func (g *Gui) SetSliderRange(slider string, rng int)

Sets a slider's range and position together, or separately.

func (g *Gui) SetContainer(grid string, c Container)

Shows a container's items in a grid.

func (g *Gui) SetGridSize(grid string, size int)

Sets the number of cells in a grid.

func (g *Gui) AddGridItem(grid string, item atl.Value)
func (g *Gui) SetGridItem(grid string, index int, item atl.Value)

Adds / replaces a grid item.

func (g *Gui) ClearGrid(grid string)

Removes every grid item.

func (g *Gui) AddListItem(list, item string, data atl.Value)

Adds an item to a list, with optional data.

func (g *Gui) ClearList(list string)

Removes every list item.

func (g *Gui) SetSelectedListItem(list, item string)

Selects a list item.

func (g *Gui) PlayEffect(widget, effect string, restart bool)
func (g *Gui) StopEffect(widget, effect string, immediate bool)

Plays / stops a widget effect.

func (g *Gui) SetHost(host atl.Wrapper, bone string)

For world GUIs (GuiWorldIcon): attaches the GUI to an object, optionally to a bone.

func (g *Gui) SetWorldPosition(p Vec3)
func (g *Gui) WorldPosition() Vec3

For world GUIs: sets / reads the world position.

func (g *Gui) SetRequireLineOfSight(required bool)

For world GUIs: whether it hides when the view is blocked.

func (g *Gui) SetMaxRenderDistance(d float64)

For world GUIs: the distance beyond which it isn't drawn.

func (g *Gui) SetFadeRange(rng float64)

For world GUIs: the distance over which it fades out.

func (g *Gui) SetOpenCloseEffect(openEffect, closeEffect string)

Effects played when the GUI opens and closes.

func (g *Gui) SetSelectedDropDownItem(dropDown, item string)

Selects a drop-down item.

func (g *Gui) SetSliderRangeLimit(slider string, limit int)

Limits how far a slider can move.

func (g *Gui) SetItemIcon(imageBox, resource, group, name string)

Shows an item icon by resource/group/name (see gui.ItemIconOf).

func (g *Gui) CreateGrid(grid string, spec GridSpec)

Creates a grid in a widget.

func (g *Gui) AddGridItemsFromFile(grid, jsonPath string, additionalData atl.Value)

Adds grid items from a JSON file.

func (g *Gui) SetContainers(grid string, containers []Container)

Shows several containers' items in a grid.

func (g *Gui) PlayGridEffect(grid string, index int, effect string, restart bool)
func (g *Gui) StopGridEffect(grid string, index int, effect string)

Plays / stops an effect on one grid item.

func (g *Gui) AddToPickupDisplay(item Uuid, amount int)
func (g *Gui) RemoveFromPickupDisplay(item Uuid, amount int)

For the survival HUD: adds to / removes from the pickup display.

func (g *Gui) CompassAddIcon(icon string, image *string, showDistance bool, width, height *int)

For gui.CreateCompassHudGui: adds an icon to the compass.

func (g *Gui) CompassRemoveIcon(icon string)

Removes a compass icon.

func (g *Gui) CompassSetIconWorldPosition(icon string, position Vec3, world World)

Places a compass icon at a world position.

func (g *Gui) CompassSetIconHost(icon string, host atl.Wrapper, joint string)

Makes a compass icon follow an object.

func (g *Gui) CompassSetIconStacking(icon string, stacking bool)

Whether a compass icon stacks with nearby icons.

func (g *Gui) CompassPingMarker(icon, effect string, color *Color)

Plays a ping effect on a compass icon.

func (g *Gui) TrackQuest(name, title string, mainQuest bool, tasks []QuestTask, icon *string)

Shows a quest in the tracker.

func (g *Gui) UntrackQuest(name string)

Removes a quest from the tracker.

func (g *Gui) OnButton(button string, fn func()) *Gui

Called when a button is clicked.

func (g *Gui) OnTextChanged(editBox string, fn func(text string)) *Gui

Called with an edit box's text whenever it changes.

func (g *Gui) OnTextAccepted(editBox string, fn func(text string)) *Gui

Called with an edit box's text when Enter is pressed.

func (g *Gui) OnSlider(slider string, fn func(position int)) *Gui

Called with a slider's new position.

func (g *Gui) HorizontalSlider(widget string, rng, value int, fn func(position int), numbered bool) *Gui
func (g *Gui) VerticalSlider(widget string, rng, value int, fn func(position int)) *Gui

Turns a widget into a horizontal / vertical slider, called with its new position.

func (g *Gui) DropDown(widget string, options []string, fn func(option string)) *Gui

Turns a widget into a drop-down, called with the selected option.

func (g *Gui) OnGridButton(button string, fn func(index int, item atl.Value)) *Gui

Called with the index and item data when a grid button is clicked.

func (g *Gui) OnGridItemClicked(grid string, fn func(index int, item atl.Value)) *Gui

Called with the index and item data when a grid item is clicked.

func (g *Gui) OnListSelection(list string, fn func(args atl.Value)) *Gui

Called when a list item is selected (engine-defined arguments).

func (g *Gui) OnOpen(fn func()) *Gui

Called when the GUI opens.

func (g *Gui) OnClose(fn func()) *Gui

Called when the GUI closes.

func (g *Gui) ClearOnClose() *Gui

Removes the OnClose handler (a destroyOnClose GUI is still cleaned up when it closes).

func (g *Gui) OnGridItemChanged(grid string, fn func(args atl.Value)) *Gui

Called when a grid item changes (engine-defined arguments, e.g. grid, index, item).

func (g *Gui) OnGridMouseFocus(button string, fn func(args atl.Value)) *Gui

Called when the mouse enters or leaves a grid item (engine-defined arguments).

func (g *Gui) OnDressbotUnlock(fn func(item Uuid)) *Gui

For dress bot GUIs: called with the unlocked customization item.

type GridSpec struct {
Type string
Layout string
ItemWidth, ItemHeight, ItemCount int
}

Describes a grid for CreateGrid.

type QuestTask struct {
Name string
Text string
Count int
Target int
Complete bool
}

A quest task shown by TrackQuest (for gui.CreateQuestTrackerGui).

type Vec3 struct {
X, Y, Z float64
}

A 3D vector (sm.vec3). Plain value type; arithmetic happens in WASM.

func Vec3Zero() Vec3
func Vec3One() Vec3

(0, 0, 0) and (1, 1, 1).

func Vec3Bezier2(c0, c1, c2 Vec3, t float64) Vec3

Point on a quadratic Bezier curve at t (0..1).

func Vec3Bezier3(c0, c1, c2, c3 Vec3, t float64) Vec3

Point on a cubic Bezier curve at t (0..1).

Methods

func (v Vec3) Add(o Vec3) Vec3
func (v Vec3) Sub(o Vec3) Vec3
func (v Vec3) Mul(o Vec3) Vec3
func (v Vec3) Div(o Vec3) Vec3
func (v Vec3) Scale(s float64) Vec3
func (v Vec3) DivS(s float64) Vec3
func (v Vec3) Neg() Vec3

Component-wise arithmetic, and scaling by a number.

func (v Vec3) Dot(o Vec3) float64

Dot product.

func (v Vec3) Cross(o Vec3) Vec3

Cross product.

func (v Vec3) Length2() float64

Squared length (cheaper than Length()).

func (v Vec3) Length() float64

Length.

func (v Vec3) Distance(o Vec3) float64

Distance to another point.

func (v Vec3) Normalize() Vec3

Unit vector in the same direction; a zero vector stays zero.

func (v Vec3) Distance2(o Vec3) float64

Squared distance to another point.

func (v Vec3) SafeNormalize(fallback Vec3) Vec3

Unit vector in the same direction, or fallback for a zero vector.

func (v Vec3) Lerp(to Vec3, t float64) Vec3

Linear interpolation towards to.

func (v Vec3) FuzzyEquals(o Vec3, eps float64) bool

True when the two vectors are within eps of each other.

func (v Vec3) Abs() Vec3
func (v Vec3) Floor() Vec3
func (v Vec3) Ceil() Vec3

Component-wise absolute value, floor and ceil.

func (v Vec3) Min(o Vec3) Vec3
func (v Vec3) Max(o Vec3) Vec3

Component-wise minimum and maximum.

func (v Vec3) Rotate(radians float64, axis Vec3) Vec3

This vector rotated radians around axis (same convention as QuatAngleAxis).

func (v Vec3) RotateX(radians float64) Vec3
func (v Vec3) RotateY(radians float64) Vec3
func (v Vec3) RotateZ(radians float64) Vec3

Rotation around a world axis.

func (v Vec3) ClosestAxis() Vec3

The axis-aligned unit vector closest to this direction.

func (v Vec3) String() string

Text forms for Format and logging.

func (v Vec3) IntoLua() atl.Value
func (v *Vec3) FromLua(x atl.Value)

Conversions to and from the game's Lua vec3, quat, color and uuid userdata.

func (v Vec3) WireEncode(w *wire.Writer)
func (v *Vec3) WireDecode(r *wire.Reader)
func (Vec3) WireSchema() uint32

Vec3, Quat and Color as their components; Uuid as its 36-character text.

type Quat struct {
X, Y, Z, W float64
}

A rotation quaternion (sm.quat). Plain value type; the zero Quat is passed to the game as no rotation.

func QuatIdentity() Quat

No rotation.

func QuatAngleAxis(radians float64, axis Vec3) Quat

A rotation of radians around axis.

func QuatFromEuler(degrees Vec3) Quat

A rotation from Euler angles in degrees (sm.quat.fromEuler).

func QuatLookRotation(at, up Vec3) Quat

A rotation facing at with up as up (sm.quat.lookRotation).

func QuatFromTo(from, to Vec3) Quat

The shortest rotation taking direction from to direction to (sm.vec3.getRotation).

func QuatRotX90() Quat
func QuatRotY90() Quat
func QuatRotZ90() Quat
func QuatRotNegX90() Quat
func QuatRotNegY90() Quat
func QuatRotNegZ90() Quat
func QuatRotX180() Quat
func QuatRotY180() Quat
func QuatRotZ180() Quat

Methods

func (q Quat) At() Vec3
func (q Quat) Up() Vec3
func (q Quat) Right() Vec3

The rotated forward, up and right directions (Quat:getAt/getUp/getRight).

func (q Quat) Round90() Quat

Snapped to the nearest 90 degree steps.

func (q Quat) SafeNormalize(fallback Quat) Quat

Normalized, or fallback if the quaternion has zero length.

func (q Quat) Mul(o Quat) Quat

Combines rotations: a.Mul(b) applies b, then a.

func (q Quat) Rotate(v Vec3) Vec3

Rotates a vector.

func (q Quat) Inverse() Quat

The opposite rotation.

func (q Quat) Normalize() Quat

Unit length; a zero quaternion becomes the identity.

func (q Quat) Slerp(to Quat, t float64) Quat

Spherical interpolation towards to along the shortest path.

func (q Quat) String() string
func (q Quat) IntoLua() atl.Value
func (q *Quat) FromLua(x atl.Value)
func (q Quat) WireEncode(w *wire.Writer)
func (q *Quat) WireDecode(r *wire.Reader)
func (Quat) WireSchema() uint32
type Color struct {
R, G, B, A float64
}

An RGBA color (sm.color) with channels from 0 to 1.

func White() Color

White.

func ColorRGB(hex uint32) Color

A color from 0xRRGGBB, e.g. sm.ColorRGB(0x4a90d9).

func ColorRGBA(hex uint32) Color

A color from 0xRRGGBBAA.

func ColorHex(s string) Color

A color from "#rrggbb", "rrggbb", "#rrggbbaa" or "rrggbbaa".

Methods

func (c Color) Lerp(to Color, t float64) Color

Linear interpolation towards to.

func (c Color) HexString() string

"rrggbbaa", as Color:getHexStr().

func (c Color) Tag() string

"#rrggbb", the color tag used in chat and GUI text.

func (c Color) GuiString() string

The engine's GUI color string, as Color:getGuiColorStr().

func (c Color) UintRgba() uint32

0xRRGGBBAA, as Color:getUintRgba().

func (c Color) String() string
func (c Color) IntoLua() atl.Value
func (c *Color) FromLua(x atl.Value)
func (c Color) WireEncode(w *wire.Writer)
func (c *Color) WireDecode(r *wire.Reader)
func (Color) WireSchema() uint32
type Uuid [16]byte

A uuid (sm.uuid), stored as its 16 bytes. The zero Uuid is the nil uuid.

func ParseUuid(s string) Uuid

Parses the text form; missing or invalid characters become '0'.

func UuidRandom() Uuid

A random uuid.

func UuidNamed(ns Uuid, name string) Uuid

A version 5 uuid: the same name in the same ns always gives the same uuid.

Methods

func (u Uuid) IsNil() bool

True for the nil uuid.

func (u Uuid) String() string

The 36-character text.

func (u Uuid) IntoLua() atl.Value
func (u *Uuid) FromLua(x atl.Value)
func (u Uuid) WireEncode(w *wire.Writer)
func (u *Uuid) WireDecode(r *wire.Reader)
func (Uuid) WireSchema() uint32
type BlueprintVisualization struct{ atl.Object }

[client] A ghost of a blueprint in the world.

Methods

func (b BlueprintVisualization) SetPosition(p Vec3)
func (b BlueprintVisualization) SetRotation(q Quat)
func (b BlueprintVisualization) SetScale(s Vec3)

Moves, rotates and scales the ghost.

func (b BlueprintVisualization) SetVisualizationColor(color string)

How it's drawn, e.g. "valid" / "invalid".

func (b BlueprintVisualization) UpdateBuilderGuide()

For builder guides: call when the guided creation changes.

func (b BlueprintVisualization) Destroy()

Removes the ghost.

type CullSphereGroup struct{ atl.Object }

Tracks which of many spheres (by id) are near a moving point.

Methods

func (c CullSphereGroup) AddSphere(id int, position Vec3, radius float64)

Adds a sphere. Duplicate ids are ignored.

func (c CullSphereGroup) RemoveSphere(id int)

Removes a sphere.

func (c CullSphereGroup) Delta(position Vec3, innerRadius, outerRadius float64) CullSphereDelta

Spheres that left outerRadius / entered innerRadius since the last call.

func (c CullSphereGroup) Overlaps(position Vec3, radius float64) []int

Ids of every sphere overlapping a sphere at position.

func (c CullSphereGroup) Leave() []int

Leaves every active sphere, returning their ids.

type CullSphereDelta struct {
Removed, Added []int
}

Ids of the spheres that left and entered.

type BuilderGuide struct{ atl.Object }

Compares a creation against a blueprint, stage by stage.

Methods

func (b BuilderGuide) ID() int

The guide's id.

func (b BuilderGuide) CurrentStageIndex() int

The stage being built.

func (b BuilderGuide) IsComplete() bool

True when every stage is built.

func (b BuilderGuide) Update()

Rechecks the creation; call whenever it changes.

func (b BuilderGuide) Destroy()

Destroys the guide.

func (b BuilderGuide) StageInfo() BuilderGuideStage

Reads the current stage's progress.

func (b BuilderGuide) ErrorInfo() BuilderGuideErrors

Reads the recorded mismatches (needs recordErrors).

type BuilderGuideStage struct {
BlocksLeft, PartsLeft, JointsLeft, ConnectionsLeft int
}

What remains to be built in the current stage.

type BuilderGuideErrors struct {
Blocks, Parts, Joints, Connections, ConnectionsReversed int
}

Counts of mismatches against the blueprint.

type JsonWidget struct{ atl.Object }

A widget of a JsonGui. All [client].

Methods

func (w JsonWidget) SetVisible(visible bool)

Shows or hides the widget.

func (w JsonWidget) SetPosition(x, y int)

Moves the widget (in 720p units) without changing its JSON.

func (w JsonWidget) SetPreview(item Uuid)

Shows an item preview.

func (w JsonWidget) SetBlueprintPreview(blueprintPath string)

Shows a blueprint preview by path.

func (w JsonWidget) ClearPreview()

Removes the preview.

func (w JsonWidget) UserString(key string) string
func (w JsonWidget) SetUserString(key, value string)

Reads / writes a string stored on the widget.

func (w JsonWidget) Effect(name string) Effect

An effect attached to the widget.

func (w JsonWidget) StartEffect(name string)
func (w JsonWidget) StopEffect(name string, immediate bool)

Starts / stops an effect attached to the widget.

func (w JsonWidget) IsEffectPlaying(name string) bool
func (w JsonWidget) IsEffectDone(name string) bool

Whether an attached effect is playing / has finished.

type JsonGui struct{ atl.Object }

A GUI built from a table "DOM" (see the game's JsonGui docs) instead of a .layout file.

Methods

func (g JsonGui) Render(dom atl.Value, forceProperties bool)

Re-renders from dom; forceProperties re-applies unchanged properties too.

func (g JsonGui) Widget(name string) JsonWidget

A widget by name.

func (g JsonGui) WidgetAbsolutePosition(name string) JsonGuiPosition

A widget's position on screen.

func (g JsonGui) IsActive() bool

True while open.

func (g JsonGui) IsHidden() bool

True while hidden.

func (g JsonGui) SetHidden(hidden bool)

Hides or shows the GUI.

func (g JsonGui) Close()

Closes the GUI.

func (g JsonGui) ClearOnCloseCallback()

Removes the on-close callback.

type JsonGuiPosition struct {
Left, Top float64
}

A position in 720p units.

type InputBlock struct {
Primary, Secondary bool
}

What a tool's ClientOnEquippedUpdate returns: whether to block the primary / secondary input from reaching the game.

Methods

func (b InputBlock) IntoLua() atl.Value

Tool input blocking, returned to the engine as two values.

type ScriptClass struct {
// contains filtered or unexported fields
}

Base of every script class. One Go object exists per game script instance. Embed it through ShapeClass, ToolClass, ... and define the callbacks you need (see ScriptCallbacks); only defined callbacks exist on the game-side class. Server* callbacks run only on the server, Client* callbacks only on clients. Callbacks keep the game's names: server_onCreate is ServerOnCreate.

Methods

func (s *ScriptClass) Self() atl.Value

The Lua script instance (self).

func (s *ScriptClass) Network() Network

self.network, for network calls between the server and client sides.

func (s *ScriptClass) Data() atl.Value

self.data: the class's data from its JSON definition.

func (s *ScriptClass) Storage() Storage

[server] self.storage: data kept for the next time this object loads.

func (s *ScriptClass) CallBase(method string, args ...any) atl.Value

Calls the Lua base class's version of method (see scriptClass's base argument) and returns its first result. Does nothing and returns nil when the base has no such method.

type ScriptCallbacks interface {
// Called once when the object is created on the server / a client.
ServerOnCreate()
ClientOnCreate()
// Called when the object is destroyed on the server / a client.
ServerOnDestroy()
ClientOnDestroy()
// Called after the script file is reloaded (dev mode).
ServerOnRefresh()
ClientOnRefresh()
// Called every physics tick (40 per second); dt is in seconds.
ServerOnFixedUpdate(dt float64)
ClientOnFixedUpdate(dt float64)
// [client] Called every frame.
ClientOnUpdate(dt float64)
// [client] Called with data the server set with Network.SetClientData.
ClientOnClientDataUpdate(data atl.Value, channel int)
// [server] Called when the object receives a network update.
ServerOnReceiveUpdate()
// [client] Called when the local player moves to another world.
ClientOnLocalPlayerChangedWorld(world World)
}

The callbacks every script class can define.

type ShapeClass struct{ ScriptClass }

A part or block script (scriptClass for a shape). Its callbacks are ShapeCallbacks.

Methods

func (s *ShapeClass) Shape() Shape

The shape this script runs on.

func (s *ShapeClass) Interactable() Interactable

The shape's interactable.

type ShapeCallbacks interface {
ScriptCallbacks
// [client] Called when a player presses / releases the interact key on the part.
ClientOnInteract(character Character, pressed bool)
// [client] Whether the part can be interacted with now; also the place to set the interaction text.
ClientCanInteract(character Character) bool
// [client] Called when a player presses / releases the tinker key on the part.
ClientOnTinker(character Character, pressed bool)
// [client] Whether the part can be tinkered with now.
ClientCanTinker(character Character) bool
// [client] Called for movement and other input actions while a player is seated in the part.
ClientOnAction(action int, pressed bool)
// Whether the part may be removed now.
ServerCanErase() bool
ClientCanErase() bool
// [client] Whether the part may be picked up.
ClientCanCarry() bool
// [server] Called when the part unloads with its cell.
ServerOnUnload()
// [server] Called when the part is hit with a sledgehammer.
ServerOnSledgehammer()
// Called when a projectile hits the part.
ServerOnProjectile(hit ProjectileHit)
ClientOnProjectile(hit ProjectileHit)
// Called when a melee attack hits the part.
ServerOnMelee(hit MeleeHit)
ClientOnMelee(hit MeleeHit)
// [server] Called when an explosion hits the part.
ServerOnExplosion(center Vec3, destructionLevel, damage int)
// Called when the part collides with something.
ServerOnCollision(hit CollisionHit)
ClientOnCollision(hit CollisionHit)
// [client] Called when interacting through a child joint (e.g. a bearing). `pressed` is always true.
ClientOnInteractThroughJoint(character Character, pressed bool, joint Joint)
// [client] Whether interacting through a child joint is allowed.
ClientCanInteractThroughJoint(character Character, joint Joint) bool
// [client] How many more parent / child connections of type `flags` are allowed (1+ allows one).
// Only called when the class's maxParentCount / maxChildCount field is 1 or more.
ClientGetAvailableParentConnectionCount(flags Connection) int
ClientGetAvailableChildConnectionCount(flags Connection) int
// [client] Called when a child joint is removed.
ClientOnChildJointRemoved(joint Joint)
// [server] Called when the part moves to another world.
ServerOnWorldChanged()
}

The callbacks a ShapeClass can define.

type ToolClass struct{ ScriptClass }

A tool script. Its callbacks are ToolCallbacks.

Methods

func (s *ToolClass) Tool() Tool

The tool this script runs on.

func (s *ToolClass) Owner() Player

The player holding the tool.

func (s *ToolClass) IsLocal() bool

True on the client of the player who owns the tool.

func (s *ToolClass) IsEquipped() bool

True while the tool is equipped.

type ToolCallbacks interface {
ScriptCallbacks
// [client] Called when the tool is equipped / unequipped.
ClientOnEquip(animate bool)
ClientOnUnequip(animate bool)
// [client] Called every frame while equipped with the primary and secondary input states.
// Return which inputs to block from the game.
ClientOnEquippedUpdate(primaryState, secondaryState int) InputBlock
// [client] Called on the toggle / reload key; return true to consume the key.
ClientOnToggle() bool
ClientOnReload() bool
// [client] Whether the tool can be equipped now.
ClientCanEquip() bool
}

The callbacks a ToolClass can define.

type CharacterClass struct{ ScriptClass }

A character script (scriptClass for a character type). Its callbacks are CharacterCallbacks.

Methods

func (s *CharacterClass) Character() Character

The character this script runs on.

type CharacterCallbacks interface {
ScriptCallbacks
// [client] Called when the character's graphics load / unload.
ClientOnGraphicsLoaded()
ClientOnGraphicsUnloaded()
// [client] Called when a player interacts with the character.
ClientOnInteract(character Character, pressed bool)
// [client] Whether the character can be interacted with now.
ClientCanInteract(character Character) bool
// [client] Called for animation events.
ClientOnEvent(event string)
// [client] Called when the character is hit by a projectile, a melee attack or a collision.
ClientOnProjectile(hit ProjectileHit)
ClientOnMelee(hit MeleeHit)
ClientOnCollision(hit CollisionHit)
}

The callbacks a CharacterClass can define.

type HarvestableClass struct{ ScriptClass }

A harvestable script (trees, rocks, crops...). Its callbacks are HarvestableCallbacks.

Methods

func (s *HarvestableClass) Harvestable() Harvestable

The harvestable this script runs on.

type HarvestableCallbacks interface {
ScriptCallbacks
// [server] Called when the harvestable unloads with its cell.
ServerOnUnload()
// [client] Called when a player interacts with the harvestable.
ClientOnInteract(character Character, pressed bool)
// [client] Whether the harvestable can be interacted with now.
ClientCanInteract(character Character) bool
// [client] Called for input actions.
ClientOnAction(action int, pressed bool)
// Whether the harvestable may be removed now.
ServerCanErase() bool
ClientCanErase() bool
// [server] Called when a player removes the harvestable.
ServerOnRemoved(player Player)
// [server] Called when the harvestable catches fire.
ServerOnIgnite()
// [server] Called when the harvestable starts floating.
ServerOnFloating()
// Called when the harvestable is hit by a projectile, melee attack, explosion or collision.
ServerOnProjectile(hit ProjectileHit)
ClientOnProjectile(hit ProjectileHit)
ServerOnMelee(hit MeleeHit)
ClientOnMelee(hit MeleeHit)
ServerOnExplosion(center Vec3, destructionLevel, damage int)
ServerOnCollision(hit CollisionHit)
ClientOnCollision(hit CollisionHit)
}

The callbacks a HarvestableClass can define.

type UnitClass struct{ ScriptClass }

A unit script: the AI that controls a creature, server only. Its callbacks are UnitCallbacks.

Methods

func (s *UnitClass) Unit() Unit

The unit this script runs on.

type UnitCallbacks interface {
ScriptCallbacks
// [server] Called every AI update.
ServerOnUnitUpdate(dt float64)
// [server] Called when the unit's character is hit by a projectile, melee attack, explosion or collision.
ServerOnProjectile(hit ProjectileHit)
ServerOnMelee(hit MeleeHit)
ServerOnExplosion(center Vec3, destructionLevel, damage int)
ServerOnCollision(hit CollisionHit)
// [server] Called when the character is crushed.
ServerOnCollisionCrush()
// [server] Called when the character's color changes.
ServerOnCharacterChangedColor(color Color)
}

The callbacks a UnitClass can define.

type PlayerClass struct{ ScriptClass }

A player script (the game's player class). Its callbacks are PlayerCallbacks.

Methods

func (s *PlayerClass) Player() Player

The player this script runs on.

type PlayerCallbacks interface {
ScriptCallbacks
// [client] Called when the player interacts with a character.
ClientOnInteract(character Character, pressed bool)
// [client] Called on the cancel, skip dialog and reload keys.
ClientOnCancel()
ClientOnSkipDialog()
ClientOnReload()
// [server] Called when the player's character is hit by a projectile, melee attack, explosion or collision.
ServerOnProjectile(hit ProjectileHit)
ServerOnMelee(hit MeleeHit)
ServerOnExplosion(center Vec3, destructionLevel, damage int)
ServerOnCollision(hit CollisionHit)
// [server] Called when the player's character is crushed.
ServerOnCollisionCrush()
// [server] Called with the items a removed shape gave the player.
ServerOnShapeRemoved(items atl.Value)
// [server] Called when the player's inventory changes.
ServerOnInventoryChanges(inventory Container, changes atl.Value)
}

The callbacks a PlayerClass can define.

type WorldClass struct{ ScriptClass }

A world script. Its callbacks are WorldCallbacks.

Methods

func (s *WorldClass) World() World

The world this script runs on.

type WorldCallbacks interface {
ScriptCallbacks
// [server] Called when the world unloads.
ServerOnUnload()
// Called when the world's terrain is first created / loaded.
ServerOnTerrainCreated()
ServerOnTerrainLoaded()
ClientOnTerrainCreated()
ClientOnTerrainLoaded()
// [server] Called when a cell is first created, loaded or unloaded.
ServerOnCellCreated(x, y int)
ServerOnCellLoaded(x, y int)
ServerOnCellUnloaded(x, y int)
// [client] Called when a cell is loaded / unloaded.
ClientOnCellLoaded(x, y int)
ClientOnCellUnloaded(x, y int)
// [server] Called when an interactable is created / destroyed in the world.
ServerOnInteractableCreated(i Interactable)
ServerOnInteractableDestroyed(i Interactable)
// Called when a projectile hits something in the world.
ServerOnProjectile(hit WorldProjectileHit)
ClientOnProjectile(hit WorldProjectileHit)
// [server] Called when a projectile is fired in the world.
ServerOnProjectileFire(position, velocity Vec3, projectile string, shooter Target, uuid Uuid)
// [server] Called when a melee attack hits something in the world.
ServerOnMelee(hit WorldMeleeHit)
// [server] Called when an explosion happens in the world.
ServerOnExplosion(center Vec3, destructionLevel, damage int)
// Called on collisions in the world.
ServerOnCollision(hit WorldCollision)
ClientOnCollision(hit WorldCollision)
// [server] Voxels removed / added by a player or creation: per-material density tables and positions.
ServerOnVoxelDestruction(densityLoss, positions atl.Value)
ServerOnVoxelConstruction(densityGain, positions atl.Value)
// [server] Mining loot to spawn (see World.SetMiningConfig).
ServerOnMining(spawns []MineSpawn)
}

The callbacks a WorldClass can define.

type ScriptableObjectClass struct{ ScriptClass }

A scriptable object script: a script with no body in the world. Its callbacks are ScriptableObjectCallbacks.

Methods

func (s *ScriptableObjectClass) ScriptableObject() ScriptableObject

The scriptable object this script runs on.

func (s *ScriptableObjectClass) Params() atl.Value

The params it was created with.

type ScriptableObjectCallbacks interface {
ScriptCallbacks
// [server] Called when the object unloads.
ServerOnUnload()
}

The callbacks a ScriptableObjectClass can define.

type ClientScriptableObjectClass struct{ ScriptClass }

A scriptable object that exists on one client only (clientscriptableobjects.Create). Its callbacks are ScriptCallbacks.

Methods

func (s *ClientScriptableObjectClass) ScriptableObject() ClientScriptableObject

The scriptable object this script runs on.

func (s *ClientScriptableObjectClass) Params() atl.Value

The params it was created with.

type TerrainScript struct{ ScriptClass }

A terrain generation script. The world class's terrainScript file runs one per generator thread, each in its own Lua state. Define what your terrain provides (see TerrainCallbacks); the engine calls Init, then Load (or Create when Load returns false), then PrepareCell before each cell's Get* queries. The Lua side is sm.allthelanguages.terrainScript.

type CullingZoneTree struct {
Portals, Zones atl.Value
}

Culling portals and zones.

Methods

func (c CullingZoneTree) IntoLua() atl.Value
type TerrainCallbacks interface {
ScriptCallbacks
// Called first, with the world and this generator thread's index.
Init(world World, generatorIndex int)
// Loads saved terrain data. Return true if it was loaded; false makes the engine call Create.
Load() bool
// Generates new terrain data for the given cell bounds and seed.
Create(xMin, xMax, yMin, yMax, seed int, data atl.Value)
// Called before a cell's queries. `loadFlags` bits: creations, surface, assets, nodes, harvestables, kinematics.
PrepareCell(cellX, cellY, loadFlags int)
// The file path of a tile uuid.
GetTilePath(tile Uuid) string
// Per-vertex queries in world coordinates: height, color and the 8 material weights.
// GetHeightAt and GetClutterIdxAt take a fast path that skips the handle table.
GetHeightAt(x, y float64, lod int) float64
GetColorAt(x, y float64, lod int) TerrainColor
GetMaterialAt(x, y float64, lod int) MaterialWeights
// The clutter index at a point, or -1 for none.
GetClutterIdxAt(x, y float64) int
// The effect material at a point (used for footstep and impact sounds).
GetEffectMaterialAt(x, y float64) string
// Per-cell contents: arrays of the engine's terrain tables (terraintile returns them too).
GetAssetsForCell(cellX, cellY, lod int) atl.Value
GetNodesForCell(cellX, cellY int) atl.Value
GetCreationsForCell(cellX, cellY int) atl.Value
GetHarvestablesForCell(cellX, cellY, lod int) atl.Value
GetKinematicsForCell(cellX, cellY, lod int) atl.Value
GetDecalsForCell(cellX, cellY, lod int) atl.Value
// A cell's tags.
GetTagsForCell(cellX, cellY int) []string
// Cells covered by ocean: {{cellX, cellY}, ...}.
GetOceanCells() atl.Value
// High level-of-detail cells: {{x, y, z, effectName}, ...}.
GetHLodCells() atl.Value
// The culling zone tree for the whole terrain.
GetCullingZoneTree() CullingZoneTree
}

The callbacks a TerrainScript can define.

type ChatParam struct {
Type string
Name string
Optional bool
}

One parameter of a chat command: its type ("int", "string", ...), name, and whether it's optional.

type GameClass struct{ ScriptClass }

The game script of a custom game (gameClass). Its callbacks are GameCallbacks.

Methods

func (s *GameClass) BindChatCommand(command string, params []ChatParam, help string, handler func(args atl.Value))

Binds a chat command to a func, e.g. BindChatCommand("/heal", []sm.ChatParam{{"int", "amount", true}}, "Heals you", func(args atl.Value) { ... }). The handler receives the parsed parameters.

type GameCallbacks interface {
ScriptCallbacks
// [server] Called when a player joins; isNewPlayer is true on their first visit.
ServerOnPlayerJoined(player Player, isNewPlayer bool)
// [server] Called when a player leaves.
ServerOnPlayerLeft(player Player)
// [server] Called on the game's reset / restart.
ServerOnReset()
ServerOnRestart()
// [server] Challenge mode: called when saving, testing and stopping a test of a level.
ServerOnSaveLevel()
ServerOnTestLevel()
ServerOnStopTest()
// [server] Called when the game unloads.
ServerOnUnload()
// [client] Called when the loading screen is lifted.
ClientOnLoadingScreenLifted()
// [client] Called when the game language changes.
ClientOnLanguageChange(language string)
// [client] Called when the player uses /unstuck.
ClientOnUnstuck()
}

The callbacks a GameClass can define.

type ServerNetwork struct {
// contains filtered or unexported fields
}

The server half's network: sends to the client halves. Every method is server-only.

Methods

func (s ServerNetwork) SendToClients(method string, data any)

[server] Calls method(data) on every client half.

func (s ServerNetwork) SendToClient(player Player, method string, data any)

[server] Calls method(data) on one player's client half.

func (s ServerNetwork) SetClientData(data any, channel int)

[server] Syncs data to OnClientDataUpdate on every client half, including players who join later.

func (s ServerNetwork) Send(msg any)

[server] Sends a typed message (a plain struct, see atl/wire) to every client half, where On(sm.Handle(...)) receives it. Messages up to wire.MaxMessageBytes are split into packets as needed and reassembled on arrival.

func (s ServerNetwork) SendTo(player Player, msg any)

[server] Sends a typed message to one player's client half.

func (s ServerNetwork) Sync(state any, channel int)

[server] Like Send, but kept: players who join later get the latest state too. One state per channel (1 or 2); a newer sync replaces the older one. A synced state must fit in one packet (wire.ChunkBytes encoded); a bigger one is logged and not sent.

type ClientNetwork struct {
// contains filtered or unexported fields
}

The client half's network: sends to the server half.

Methods

func (c ClientNetwork) SendToServer(method string, data any)

Calls method(data, sender) on the server half.

func (c ClientNetwork) Send(msg any)

Sends a typed message to the server half's On handler (see ServerNetwork.Send).

type ScriptSide struct {
// contains filtered or unexported fields
}

Base of both halves of a split script class.

Methods

func (s *ScriptSide) Self() atl.Value

The Lua script instance (self).

func (s *ScriptSide) Data() atl.Value

self.data: the class's data from its JSON definition.

type ServerShapeClass struct{ ScriptSide }

The server half of a split part. Callbacks drop the game's server_ prefix: OnCreate is server_onCreate, and so on. See ShapeCallbacks for what each callback does, and ServerShapeCallbacks for the list. Server only: every callback and method of this half runs on the server.

Methods

func (s *ServerShapeClass) Shape() Shape

The shape this script runs on.

func (s *ServerShapeClass) Interactable() Interactable

The shape's interactable.

func (s *ServerShapeClass) Network() ServerNetwork

[server] The network, for sending to the client halves.

func (s *ServerShapeClass) Storage() Storage

[server] Data kept for the next time this part loads.

func (s *ServerShapeClass) SaveState(state any)

[server] Saves a plain struct to storage in the wire format (see atl/wire).

func (s *ServerShapeClass) LoadState(out any) bool

[server] Loads the struct SaveState saved into the struct out points to; false if there was none. A save from a build with a different definition of the struct is ignored with a warning (fields are stored by position, so it can't be read safely) and the part starts fresh.

type ServerShapeCallbacks interface {
OnCreate()
OnDestroy()
OnRefresh()
OnFixedUpdate(dt float64)
OnReceiveUpdate()
CanErase() bool
OnUnload()
OnSledgehammer()
OnProjectile(hit ProjectileHit)
OnMelee(hit MeleeHit)
OnExplosion(center Vec3, destructionLevel, damage int)
OnCollision(hit CollisionHit)
OnWorldChanged()
}

The callbacks a ServerShapeClass can define.

type ClientShapeClass struct{ ScriptSide }

The client half of a split part. Callbacks drop the game's client_ prefix: OnInteract is client_onInteract, and so on. See ShapeCallbacks for what each callback does, and ClientShapeCallbacks for the list. Client only: every callback and method of this half runs on clients.

Methods

func (s *ClientShapeClass) Shape() Shape

The shape this script runs on.

func (s *ClientShapeClass) Interactable() Interactable

The shape's interactable.

func (s *ClientShapeClass) Network() ClientNetwork

The network, for sending to the server half.

type ClientShapeCallbacks interface {
OnCreate()
OnDestroy()
OnRefresh()
OnFixedUpdate(dt float64)
OnUpdate(dt float64)
OnClientDataUpdate(data atl.Value, channel int)
OnLocalPlayerChangedWorld(world World)
OnInteract(character Character, pressed bool)
CanInteract(character Character) bool
OnTinker(character Character, pressed bool)
CanTinker(character Character) bool
OnAction(action int, pressed bool)
CanErase() bool
CanCarry() bool
OnProjectile(hit ProjectileHit)
OnMelee(hit MeleeHit)
OnCollision(hit CollisionHit)
// Called when interacting through a child joint (e.g. a bearing). `pressed` is always true.
OnInteractThroughJoint(character Character, pressed bool, joint Joint)
CanInteractThroughJoint(character Character, joint Joint) bool
// See ShapeCallbacks.ClientGetAvailableParentConnectionCount.
GetAvailableParentConnectionCount(flags Connection) int
GetAvailableChildConnectionCount(flags Connection) int
OnChildJointRemoved(joint Joint)
}

The callbacks a ClientShapeClass can define.

type Method[T any] func(obj *T, args atl.Value) atl.Value

A custom method of script class T: receives the Lua arguments, returns a Value. Fn0 ... FnR4 build one from a method with typed parameters.

func Fn0[T any](f func(*T)) Method[T]
func Fn1[T, A any](f func(*T, A)) Method[T]
func Fn2[T, A, B any](f func(*T, A, B)) Method[T]
func Fn3[T, A, B, C any](f func(*T, A, B, C)) Method[T]
func Fn4[T, A, B, C, D any](f func(*T, A, B, C, D)) Method[T]

Adapts a method with up to 4 parameters, each converted from Lua by type, and no result.

func FnR0[T, R any](f func(*T) R) Method[T]
func FnR1[T, A, R any](f func(*T, A) R) Method[T]
func FnR2[T, A, B, R any](f func(*T, A, B) R) Method[T]
func FnR3[T, A, B, C, R any](f func(*T, A, B, C) R) Method[T]
func FnR4[T, A, B, C, D, R any](f func(*T, A, B, C, D) R) Method[T]

Adapts a method with up to 4 parameters and a result converted to Lua.

type ClassDef[T any] struct {
// contains filtered or unexported fields
}

The registration of a script class, returned by Class.

func Class[T any](name string) *ClassDef[T]

Registers T as script class name, so Lua can ask for it with scriptClass("name"), with every engine callback it defines. Chain Method to add custom methods.

Methods

func (d *ClassDef[T]) Method(name string, fn Method[T]) *ClassDef[T]

Adds a custom method callable from Lua or the network (e.g. a SendToServer target), e.g. .Method("sv_toggle", sm.Fn1((*Lamp).SvToggle)).

type SideDef[T any] struct {
// contains filtered or unexported fields
}

The registration of one half of a split class, returned by ServerClass / ClientClass.

func ServerClass[T any](className string) *SideDef[T]

Registers T as the server half of split class className (see ServerShapeClass), with every callback it defines. Each half may be in its own file. Chain On and Method.

func ClientClass[T any](className string) *SideDef[T]

Registers T as the client half of split class className (see ClientShapeClass).

Methods

func (d *SideDef[T]) Method(name string, fn Method[T]) *SideDef[T]

Adds a network target or other custom method of this half. It only runs on this half's side: a call that arrives on the other side is logged and dropped.

func (d *SideDef[T]) On(h Handler[T]) *SideDef[T]

Adds a typed-message handler (Handle or HandleFrom). The other half sends it with Network().Send(Message{...}), or Sync.

type Handler[T any] struct {
// contains filtered or unexported fields
}

A typed-message handler of half T, built by Handle or HandleFrom.

func Handle[T, M any](f func(*T, M)) Handler[T]

A handler func(\*Half, Message), where Message is a plain struct.

func HandleFrom[T, M any](f func(*T, M, Player)) Handler[T]

A server-half handler that also takes the sending Player.

type Aabb struct {
Min, Max Vec3
}

An axis-aligned bounding box.

type Sticky struct {
Positive, Negative Vec3
}

The positive-xyz and negative-xyz sticky directions of a shape or joint.

type TerrainColor struct {
R, G, B float64
}

A terrain color (TerrainScript, terraintile).

Methods

func (c TerrainColor) IntoLua() atl.Value
type MaterialWeights struct {
Weights [8]float64
}

The 8 ground material weights at a terrain point.

Methods

func (m MaterialWeights) IntoLua() atl.Value
type MineSpawn struct {
Position Vec3
SpawnID int
}

One mining loot spawn (WorldClass.ServerOnMining).

Methods

func (m *MineSpawn) FromLua(v atl.Value)

A mining spawn from ServerOnMining's arguments.

type Destruction struct {
AttackLevel int
Type *int
Position *Vec3
Normal *Vec3
}

How a shape is destroyed (Type is an sm.shape.destructionType value).

type AnimationInfo struct {
Name string
Duration float64
Looping bool
}

Information about an animation: name, length in seconds, and whether it loops.

Methods

func (a *AnimationInfo) FromLua(t atl.Value)

Reads the game's animation info table.

type ActiveAnimation struct {
Name string
Weight float64
}

An animation that is playing, and its blend weight.

type Shape struct{ atl.Object }

A block or part in the world (Lua Shape).

Methods

func (s Shape) ID() int

The shape's unique id.

func (s Shape) Uuid() Uuid

The shape's item uuid.

func (s Shape) Body() Body

The body the shape belongs to.

func (s Shape) Interactable() Interactable

The shape's interactable, or empty for a plain block.

func (s Shape) WorldPosition() Vec3
func (s Shape) WorldRotation() Quat
func (s Shape) LocalPosition() Vec3
func (s Shape) LocalRotation() Quat

Position and rotation in the world, and relative to the body.

func (s Shape) Velocity() Vec3

Velocity in meters per second.

func (s Shape) At() Vec3
func (s Shape) Up() Vec3
func (s Shape) Right() Vec3

The shape's forward (at), up and right directions in the world.

func (s Shape) XAxis() Vec3
func (s Shape) YAxis() Vec3
func (s Shape) ZAxis() Vec3

The shape's local x, y and z axes in world space.

func (s Shape) BoundingBox() Vec3

Size in blocks.

func (s Shape) LocalAabb() Aabb

The bounding box in body-local coordinates.

func (s Shape) Mass() float64

Mass in kilograms.

func (s Shape) Material() string

The physics material name.

func (s Shape) Color() Color

The paint color.

func (s Shape) SetColor(c Color)

[server] Paints the shape.

func (s Shape) Burning() bool

True while the shape burns.

func (s Shape) SetBurning(b bool)

[server] Sets the shape on fire or puts it out.

func (s Shape) TransformPoint(worldPoint Vec3) Vec3
func (s Shape) TransformDirection(worldDir Vec3) Vec3

World point / direction to shape-local.

func (s Shape) TransformLocalPoint(localPoint Vec3) Vec3
func (s Shape) TransformLocalDirection(localDir Vec3) Vec3

Shape-local point / direction to world.

func (s Shape) Joints(onlyChildJoints bool) []Joint

Joints attached to the shape, optionally only those it's the parent of.

func (s Shape) Neighbours() []Shape

[server] Shapes touching this one.

func (s Shape) InterpolatedWorldPosition() Vec3
func (s Shape) InterpolatedAt() Vec3
func (s Shape) InterpolatedUp() Vec3
func (s Shape) InterpolatedRight() Vec3

Positions and directions smoothed between physics ticks, for rendering.

func (s Shape) TransformRotation(worldRotation Quat) Quat

A world rotation in shape-local terms.

func (s Shape) ClosestBlockLocalPosition(worldPosition Vec3) Vec3

The local position of the shape's block nearest to a world position.

func (s Shape) Buoyancy() float64

Buoyancy of the shape's material.

func (s Shape) MaterialID() int

The physics material id.

func (s Shape) SetPhysicsMaterial(material int)

[client] Overrides the physics material.

func (s Shape) SetCollisionSoundEnabled(on bool)

Turns collision sounds on or off.

func (s Shape) IsHarvest() bool

True for a harvested item.

func (s Shape) IsStackable() bool

True if the item stacks.

func (s Shape) Sticky() Sticky

The sticky directions.

func (s Shape) Compromised() bool

True when the shape is structurally weakened.

func (s Shape) SetCompromised(on bool)

[server] Weakens or restores the shape.

func (s Shape) RemoveColor()

[server] Back to the shape's default color.

func (s Shape) ApplyShakeImpulse(shake float64)

[client] Shakes the shape visually.

func (s Shape) MultiShapeShapes() []Shape
func (s Shape) MultiShapeJoints() []Joint

The shapes and joints of the multi-shape item this shape belongs to.

func (s Shape) IsPipe() bool

True for pipe parts.

func (s Shape) PipeOffsets(direction *int) []Vec3

Pipe connection offsets, optionally for one direction only.

func (s Shape) PipedNeighbours() []Shape

[server] Pipes connected to this one.

func (s Shape) OutputContainerIndex() int

The output container index from the shapeset, for pipe graphs.

func (s Shape) ApplyImpulse(impulse Vec3, worldSpace bool, offset Vec3)

[server] Applies an impulse (sm.physics.applyImpulse), in local space unless worldSpace.

func (s Shape) Destroy(attackLevel int)

[server] Destroys the shape with an attack level.

func (s Shape) DestroyWith(d Destruction)

[server] Destroys the shape with full destruction details.

func (s Shape) DestroyBlock(localPosition, size Vec3, d Destruction)

[server] Removes the blocks of a block shape in the box at localPosition (a corner) of size.

func (s Shape) Replace(uuid Uuid)

[server] Replaces the shape with another item, keeping its position.

func (s Shape) CreateJoint(uuid Uuid, localPosition, direction Vec3) Joint

[server] Creates a joint on this shape at grid localPosition, facing direction.

type Body struct{ atl.Object }

A rigid body: shapes connected without joints (Lua Body).

Methods

func (b Body) ID() int

The body's id.

func (b Body) CreationID() int

[server] The id of the creation (bodies connected by joints) it belongs to.

func (b Body) World() World

The world the body is in.

func (b Body) WorldPosition() Vec3

Position of the body's origin.

func (b Body) CenterOfMass() Vec3

Center of mass in world space.

func (b Body) Velocity() Vec3
func (b Body) AngularVelocity() Vec3

Linear / angular velocity.

func (b Body) Mass() float64

Mass in kilograms.

func (b Body) LocalAabb() Aabb
func (b Body) WorldAabb() Aabb

Bounding box in body-local / world coordinates.

func (b Body) Shapes() []Shape
func (b Body) Interactables() []Interactable
func (b Body) Joints() []Joint

The body's shapes, interactables and joints.

func (b Body) CreationBodies() []Body
func (b Body) CreationShapes() []Shape
func (b Body) CreationJoints() []Joint

The bodies, shapes and joints of the whole creation.

func (b Body) SeatedCharacters() []Character

[server] Characters seated in the body.

func (b Body) ShapeCount() int

Number of shapes.

func (b Body) Shape(index int) Shape

Shape by index.

func (b Body) ShapesByUuid(uuid Uuid) []Shape

Shapes of one item type.

func (b Body) HasChanged(tick int) bool

True if the body changed after tick (compare with game.CurrentTick()).

func (b Body) Lift() Lift

The lift the body is on (empty if none).

func (b Body) IsGhost() bool

True for a ghost (non-colliding) body.

func (b Body) IsOnVirtualLift() bool

True when held by a virtual lift.

func (b Body) IsConnectable() bool
func (b Body) IsLiftable() bool
func (b Body) IsConvertibleToDynamic() bool

Permission flags: whether the body can be connected to, lifted, or made dynamic.

func (b Body) SetConnectable(v bool)
func (b Body) SetLiftable(v bool)
func (b Body) SetConvertibleToDynamic(v bool)

[server] Sets those permission flags.

func (b Body) IsStatic() bool
func (b Body) IsDynamic() bool

True if the body is static / dynamic.

func (b Body) IsOnLift() bool

True when on a lift.

func (b Body) IsBuildable() bool
func (b Body) IsDestructable() bool
func (b Body) IsErasable() bool
func (b Body) IsPaintable() bool
func (b Body) IsUsable() bool

Permission flags: building, destruction, erasing, painting and use.

func (b Body) SetBuildable(v bool)
func (b Body) SetDestructable(v bool)
func (b Body) SetErasable(v bool)
func (b Body) SetPaintable(v bool)
func (b Body) SetUsable(v bool)

[server] Sets those permission flags.

func (b Body) TransformPoint(worldPoint Vec3) Vec3

World point to body-local.

func (b Body) TransformLocalPoint(localPoint Vec3) Vec3

Body-local point to world.

func (b Body) TransformWorldPoint(worldPoint Vec3) Vec3

World space to the body's local space.

func (b Body) ApplyImpulse(impulse Vec3, worldSpace bool, offset Vec3)

[server] Applies an impulse (sm.physics.applyImpulse), in local space unless worldSpace.

func (b Body) ApplyTorque(torque Vec3, worldSpace bool)

[server] Applies a torque (sm.physics.applyTorque), in local space unless worldSpace.

func (b Body) CreateBlock(uuid Uuid, size, localPosition Vec3, forceAccept bool) Shape

[server] Adds a block. forceAccept skips the overlap check.

func (b Body) CreatePart(uuid Uuid, localPosition, zAxis, xAxis Vec3, forceAccept bool) Shape

[server] Adds a part oriented by its z and x axes.

func (b Body) CreateWedge(uuid Uuid, size, localPosition, zAxis, xAxis Vec3, forceAccept bool)

[server] Adds a wedge.

func (b Body) DestroyCreation()

[server] Destroys the whole creation.

type Connection int

Connection types between interactables, combinable with |.

const (
ConnectionNone Connection = 0
ConnectionLogic Connection = 1
ConnectionPower Connection = 2
ConnectionBearing Connection = 4
ConnectionSeated Connection = 8
ConnectionPiston Connection = 16
ConnectionGasoline Connection = 256
ConnectionElectricity Connection = 512
ConnectionWater Connection = 1024
ConnectionAmmo Connection = 2048
)
type Interactable struct{ atl.Object }

The scripted, connectable side of a part (Lua Interactable).

Methods

func (i Interactable) ID() int

The interactable's id.

func (i Interactable) Shape() Shape
func (i Interactable) Body() Body

The shape and body it belongs to.

func (i Interactable) Type() string

The interactable type, e.g. "engine".

func (i Interactable) IsActive() bool

True when active (on).

func (i Interactable) SetActive(on bool)

[server] Turns the interactable on or off.

func (i Interactable) Power() float64

The output power value.

func (i Interactable) SetPower(p float64)

[server] Sets the output power.

func (i Interactable) Parents(filter *Connection) []Interactable
func (i Interactable) Children(filter *Connection) []Interactable

Interactables connected as inputs / outputs, optionally of one connection type.

func (i Interactable) SingleParent() Interactable

The only parent, or empty.

func (i Interactable) Connect(child Interactable) bool

[server] Connects an output to child.

func (i Interactable) Disconnect(child Interactable) bool

[server] Removes a connection to child.

func (i Interactable) PublicData() atl.Value

[server] Data other scripts can read.

func (i Interactable) SetPublicData(t atl.Value)

[server] Sets data other scripts can read.

func (i Interactable) HasSeat() bool

True if the part has a seat.

func (i Interactable) SeatCharacter() Character

The character in the seat.

func (i Interactable) SetUvFrameIndex(index int)
func (i Interactable) SetGlowMultiplier(v float64)
func (i Interactable) SetAnimEnabled(name string, on bool)
func (i Interactable) SetAnimProgress(name string, progress float64)
func (i Interactable) SetSubMeshVisible(name string, visible bool)

[client] Visual state: UV frame, glow, animations and sub-mesh visibility.

func (i Interactable) Container(index int) Container

A container of the interactable by index.

func (i Interactable) AddContainer(index, size int, stackSize *int) Container

[server] Adds a container of size slots.

func (i Interactable) RemoveContainer(index int)

[server] Removes a container.

func (i Interactable) MaxParentCount() int
func (i Interactable) MaxChildCount() int

How many parents / children may connect.

func (i Interactable) InputType() Connection
func (i Interactable) OutputType() Connection

The connection types accepted as input / produced as output.

func (i Interactable) HasOutputType(flags Connection) bool

True if the output includes all of flags.

func (i Interactable) ConnectionColor() Color
func (i Interactable) ConnectionHighlightColor() Color

Connection colors (normal / highlighted).

func (i Interactable) Joints() []Joint
func (i Interactable) Bearings() []Joint
func (i Interactable) Pistons() []Joint

Connected joints: all of them, bearings only, pistons only.

func (i Interactable) ConnectToJoint(child Joint)

[server] Connects to a joint (e.g. a bearing) as its controller.

func (i Interactable) JointCustomData(joint Joint) atl.Value

Data attached to a connected joint.

func (i Interactable) SetJointCustomData(joint Joint, data atl.Value)

[server] Attaches data to a connected joint.

func (i Interactable) HasChanged(tick int) bool

True if the interactable had updates after tick.

func (i Interactable) ClientPublicData() atl.Value

[client] Data other client scripts can read.

func (i Interactable) SetClientPublicData(t atl.Value)

[client] Sets data other client scripts can read.

func (i Interactable) SetParams(data atl.Value)

Params for an interactable created from a script.

func (i Interactable) CarryData() atl.Value

[server] Data kept when the part is carried.

func (i Interactable) SetCarryData(data atl.Value)

[server] Sets data kept when the part is carried.

func (i Interactable) OnDamageDestruction(fn func())

[server] Runs when the interactable is destroyed by damage.

func (i Interactable) SetSeatCharacter(character Character)

Requests to seat character (empty to unseat).

func (i Interactable) SeatInteractables() []Interactable

Interactables the seat controls (the hotbar of a seat).

func (i Interactable) PressSeatInteractable(index int) bool
func (i Interactable) ReleaseSeatInteractable(index int) bool

Presses / releases a seat hotbar slot.

func (i Interactable) HasSteering() bool

True for a driver's seat with steering.

func (i Interactable) SteeringAngle() float64

Steering input: A = -1, D = 1.

func (i Interactable) SteeringPower() float64

Throttle input: W = 1, S = -1.

func (i Interactable) SteeringSprint() bool

True while sprinting in the seat.

func (i Interactable) SetSteeringFlag(flags int)
func (i Interactable) UnsetSteeringFlag(flags int)

Sets / clears steering flags.

func (i Interactable) SteeringJoint(joint Joint) SteeringJoint

Reads a bearing's steering settings.

func (i Interactable) SetSteeringJoint(joint Joint, s SteeringJoint)

[client] Writes a bearing's steering settings.

func (i Interactable) SteeringJointLeftAngleLimit(j Joint) float64
func (i Interactable) SteeringJointRightAngleLimit(j Joint) float64
func (i Interactable) SteeringJointLeftAngleSpeed(j Joint) float64
func (i Interactable) SteeringJointRightAngleSpeed(j Joint) float64
func (i Interactable) SteeringJointUnlocked(j Joint) bool

Read a single steering setting of a bearing.

func (i Interactable) SetSteeringJointLeftAngleLimit(j Joint, v float64)
func (i Interactable) SetSteeringJointRightAngleLimit(j Joint, v float64)
func (i Interactable) SetSteeringJointLeftAngleSpeed(j Joint, v float64)
func (i Interactable) SetSteeringJointRightAngleSpeed(j Joint, v float64)
func (i Interactable) SetSteeringJointUnlocked(j Joint, unlocked bool)

[client] Write a single steering setting of a bearing.

func (i Interactable) SetGyroDirection(direction Vec3)
func (i Interactable) SetGyroForce(force float64)
func (i Interactable) SetGyroMaxSpeed(speed float64)

[client] Gyro / turret seats: aim direction, force and maximum speed.

func (i Interactable) SetLightOverrideColor(c Color)
func (i Interactable) ClearLightOverrideColor()

[server] Overrides / restores the light color.

func (i Interactable) GlowMultiplier() float64

The current glow multiplier.

func (i Interactable) UvFrameIndex() int

[client] The current UV frame.

func (i Interactable) PoseWeight(index int) float64
func (i Interactable) SetPoseWeight(index int, weight float64)

[client] Reads / writes an animation pose weight.

func (i Interactable) HasAnim(name string) bool

[client] True if the animation exists.

func (i Interactable) AnimDuration(name string) float64

[client] An animation's length in seconds.

func (i Interactable) IsAnimLooping(name string) bool

[client] True if an animation loops.

func (i Interactable) LocalBonePosition(bone string) Vec3
func (i Interactable) WorldBonePosition(bone string) Vec3

A bone's position, local / in the world.

type SteeringJoint struct {
LeftAngleSpeed, RightAngleSpeed, LeftAngleLimit, RightAngleLimit float64
Unlocked bool
}

Steering settings of a connected bearing.

type Joint struct{ atl.Object }

A joint: bearing, piston, spring or similar (Lua Joint).

Methods

func (j Joint) ID() int

The joint's id.

func (j Joint) Type() string

The joint type, e.g. "bearing" or "piston".

func (j Joint) ShapeA() Shape

The shape the joint is placed on.

func (j Joint) ShapeB() Shape

The shape on the joint's far side; empty when nothing is attached.

func (j Joint) Uuid() Uuid

The joint's item uuid.

func (j Joint) WorldPosition() Vec3
func (j Joint) WorldRotation() Quat
func (j Joint) LocalPosition() Vec3
func (j Joint) LocalRotation() Quat

Position and rotation, in the world / on the body.

func (j Joint) XAxis() Vec3
func (j Joint) YAxis() Vec3
func (j Joint) ZAxis() Vec3

The joint's local axes in world space.

func (j Joint) BoundingBox() Vec3

Size in blocks.

func (j Joint) Color() Color

Paint color.

func (j Joint) SetColor(c Color)

[server] Paints the joint.

func (j Joint) Sticky() Sticky

The sticky directions.

func (j Joint) MultiShapeShapes() []Shape
func (j Joint) MultiShapeJoints() []Joint

The shapes and joints of its multi-shape item.

func (j Joint) Angle() float64
func (j Joint) AngularVelocity() float64

A bearing's angle in radians and angular speed.

func (j Joint) AngularVelocityVector() Vec3

Angular velocity as a vector.

func (j Joint) AppliedImpulse() float64

The impulse the motor applied last tick.

func (j Joint) BearingEnabled() bool

True if the bearing turns freely.

func (j Joint) Length() float64

A piston's current length.

func (j Joint) IsReversed() bool

True if the joint is reversed.

func (j Joint) CreateBlock(uuid Uuid, size, localPosition Vec3, forceCreate bool)
func (j Joint) CreatePart(uuid Uuid, localPosition, zAxis, xAxis Vec3, forceCreate bool)

[server] Adds a block / part on the joint's far side.

func (j Joint) SetMotorVelocity(velocity, maxImpulse float64)

Bearings: spins at velocity with up to maxImpulse.

func (j Joint) SetTargetAngle(angle, velocity, maxImpulse float64)

Bearings: turns to angle.

func (j Joint) SetTargetLength(length, velocity, maxImpulse float64)

[server] Pistons: extends to length.

type Character struct{ atl.Object }

A character: a player's body or a creature (Lua Character).

Methods

func (c Character) ID() int

The character's id.

func (c Character) Player() Player

The controlling player; empty for non-player characters.

func (c Character) IsPlayer() bool

True for a player's character.

func (c Character) World() World

The world the character is in.

func (c Character) WorldPosition() Vec3

Position in the world.

func (c Character) SetWorldPosition(p Vec3)

[server] Teleports the character.

func (c Character) Velocity() Vec3

Velocity.

func (c Character) Direction() Vec3

Look direction.

func (c Character) Mass() float64
func (c Character) Height() float64
func (c Character) Radius() float64

Mass, height and radius.

func (c Character) Color() Color

Color.

func (c Character) SetColor(col Color)

[server] Paints the character.

func (c Character) IsOnGround() bool
func (c Character) IsCrouching() bool
func (c Character) IsSprinting() bool
func (c Character) IsSwimming() bool
func (c Character) IsSeated() bool
func (c Character) IsTumbling() bool
func (c Character) IsDowned() bool

Movement state.

func (c Character) SetTumbling(v bool)

[server] Knocks the character over / lets it get up.

func (c Character) SetDowned(v bool)

[server] Downs the character or revives it.

func (c Character) SetMovementSpeedFraction(f float64)

Scales movement speed (1 is normal).

func (c Character) SetNameTag(name string, color *Color)

Shows a name tag above the character.

func (c Character) ApplyImpulse(impulse Vec3)

Pushes the character.

func (c Character) CharacterType() Uuid

The character type's uuid.

func (c Character) Unit() Unit

The AI unit controlling the character, if any.

func (c Character) SmoothViewDirection() Vec3

The look direction, smoothed.

func (c Character) SurfaceNormal() Vec3

The normal of the surface the character stands on.

func (c Character) IsDefaultColor() bool

True if the character has its default color.

func (c Character) IsMoving() bool
func (c Character) IsAiming() bool
func (c Character) IsClimbing() bool
func (c Character) IsLadderClimbing() bool
func (c Character) IsDiving() bool
func (c Character) IsFlying() bool
func (c Character) IsHovering() bool

More movement state.

func (c Character) CanSwim() bool

True if the character type can swim.

func (c Character) SetSwimming(v bool)
func (c Character) SetDiving(v bool)
func (c Character) SetClimbing(v bool)
func (c Character) SetFlying(v bool)
func (c Character) SetHovering(v bool)

[server] Forces a movement state.

func (c Character) Immovable() bool

[server] Whether the character can be pushed.

func (c Character) SetImmovable(v bool)

[server] Makes the character immovable or movable.

func (c Character) MoveSpeed() float64
func (c Character) SprintSpeed() float64

Base walking and sprinting speeds.

func (c Character) CurrentMovementSpeed() float64

The current movement speed.

func (c Character) MovementSpeedFraction() float64

The movement speed scale.

func (c Character) JumpSpeedFraction() float64
func (c Character) SetJumpSpeedFraction(f float64)

Reads / writes the jump height scale.

func (c Character) MovementNoiseRadius() float64

How far the character's movement can be heard by AI.

func (c Character) SetMovementEffects(effectSetPath string)

Sets the effect set used for footsteps and other movement sounds.

func (c Character) LockingInteractable() Interactable
func (c Character) SetLockingInteractable(i Interactable) bool
func (c Character) LockingHarvestable() Harvestable
func (c Character) SetLockingHarvestable(h Harvestable) bool

The interactable / harvestable the character is locked to (e.g. a seat or ladder), and setting it. The setters return true on success.

func (c Character) TumblingWorldPosition() Vec3
func (c Character) TumblingWorldRotation() Quat
func (c Character) TumblingLinearVelocity() Vec3
func (c Character) TumblingAngularVelocity() Vec3
func (c Character) TumblingExtent() Vec3

The tumbling (ragdoll) body's position, rotation, velocities and size.

func (c Character) ApplyTumblingImpulse(impulse Vec3, offset *Vec3)

Pushes the tumbling body.

func (c Character) SetAllowTumbleAnimations(allow bool)

Whether tumbling plays animations.

func (c Character) PublicData() atl.Value

[server] Data other server scripts can read.

func (c Character) SetPublicData(t atl.Value)

[server] Sets data other server scripts can read.

func (c Character) ClientPublicData() atl.Value

[client] Data other client scripts can read.

func (c Character) SetClientPublicData(t atl.Value)

[client] Sets data other client scripts can read.

func (c Character) TpBonePosition(bone string) Vec3
func (c Character) TpBoneRotation(bone string) Quat

A bone's third person position / rotation.

func (c Character) ActiveAnimations() []ActiveAnimation

The animations playing now.

func (c Character) AnimationInfo(name string) AnimationInfo

Information about an animation.

func (c Character) UpdateAnimation(name string, time float64, weight *float64, additive bool)

Plays an animation at time with an optional blend weight.

func (c Character) HasActiveOverrideAnimation() bool

True while an override animation plays.

func (c Character) SetMovementWeights(lower, upper float64)

Blend weights of the lower and upper body movement animations.

func (c Character) OnAnimation(name string, time float64, fn func())

Calls fn when animation name reaches time.

func (c Character) RemoveAnimationCallbacks()

Removes every OnAnimation callback.

func (c Character) HasGraphics() bool

True once the character's graphics are loaded.

func (c Character) IsVisible() bool
func (c Character) SetVisible(visible bool)

Visibility.

func (c Character) AddRenderable(rend string)
func (c Character) RemoveRenderable(rend string)

Adds / removes a renderable on the character.

func (c Character) OverrideRenderables(rends []string)

Replaces the character's renderables.

func (c Character) GlowMultiplier() float64
func (c Character) SetGlowMultiplier(v float64)

Reads / writes the glow multiplier.

func (c Character) SetUpDirection(up Vec3)

Sets which way is up for the character.

type Player struct{ atl.Object }

A connected player (Lua Player).

Methods

func (p Player) ID() int

The player's id.

func (p Player) Name() string

The player's display name.

func (p Player) Character() Character

The player's current character.

func (p Player) Inventory() Container
func (p Player) Hotbar() Container

The player's inventory and hotbar.

func (p Player) IsMale() bool
func (p Player) IsFemale() bool

The character's body type.

func (p Player) PublicData() atl.Value

[server] Data other scripts can read.

func (p Player) SetPublicData(t atl.Value)

[server] Sets data other scripts can read.

func (p Player) ClientPublicData() atl.Value

[client] Data other client scripts can read.

func (p Player) SetClientPublicData(t atl.Value)

[client] Sets data other client scripts can read.

func (p Player) IsActive() bool

True until the player has left.

func (p Player) CurrentToolUuid() Uuid

The uuid of the tool the player holds.

func (p Player) CustomizationUuid(index int) Uuid

[server] The uuid of customization slot index.

func (p Player) SetCharacter(c Character)

[server] Gives the player a character.

func (p Player) SendCharacterEvent(event string)

[server] Fires ClientOnEvent on the player's character.

func (p Player) Carry() Container

The container of the item the player carries.

func (p Player) CarryColor() Color

[server] The carried item's color.

func (p Player) CarryData() atl.Value

[server] Data of the carried item.

func (p Player) SetCarryData(t atl.Value)

[server] Sets the carried item's data.

func (p Player) PlaceLift(creation []Body, position Vec3, level, rotation int)

[server] Places the player's lift, carrying creation, at level with rotation (0..3).

func (p Player) RemoveLift()

[server] Removes the player's lift.

type Item struct {
Uuid Uuid
Quantity int
}

An item stack: uuid and quantity.

Methods

func (i Item) Empty() bool

True for no item.

func (i *Item) FromLua(t atl.Value)

Reads an item table.

type Container struct{ atl.Object }

An item container: inventory, chest, hotbar... (Lua Container).

Methods

func (c Container) Size() int

Number of slots.

func (c Container) Item(slot int) Item

The item in a slot.

func (c Container) IsEmpty() bool
func (c Container) IsFull() bool

True if every / no slot is free.

func (c Container) CanCollect(item Uuid, quantity int) bool
func (c Container) CanSpend(item Uuid, quantity int) bool

True if quantity of item fit / can be taken.

func (c Container) CanCollectAll(items []Item) bool

True if all of these items fit at once.

func (c Container) Count(item Uuid) int

Total quantity of an item.

func (c Container) MaxStackSize() int

Largest stack per slot.

func (c Container) UniqueItems() []Uuid

Each item type present, once.

func (c Container) ItemUuids() []Uuid
func (c Container) Quantities() []int

Every slot's uuid / quantity, in slot order.

func (c Container) FirstItem() Item

The first non-empty slot's item.

func (c Container) Revision() int

Network revision, bumped on every change.

func (c Container) HasChanged(tick int) bool

[server] True if the container changed after tick.

func (c Container) AllowCollect() bool
func (c Container) AllowSpend() bool

[server] Whether items can be put in / taken out.

func (c Container) MoveAllToCarry(player Player, color Color)

[server] Moves everything into player's carry container, painted color.

func (c Container) Collect(item Uuid, quantity int, mustCollectAll bool) int
func (c Container) Spend(item Uuid, quantity int, mustSpendAll bool) int

[server] Adds / removes items; returns how many were moved. Use inside container.Transaction.

func (c Container) CollectToSlot(slot int, item Uuid, quantity int, mustCollectAll bool) int
func (c Container) SpendFromSlot(slot int, item Uuid, quantity int, mustSpendAll bool) int

[server] Adds to / takes from one slot.

func (c Container) Swap(other Container, fromSlot, toSlot int) bool

[server] Swaps slots with another container.

func (c Container) MoveAllTo(other Container)

[server] Moves everything to another container.

func (c Container) SetItem(slot int, item Uuid, quantity int) bool
func (c Container) Clear()
func (c Container) Resize(size int, stackSize *int)
func (c Container) SetAllowCollect(allow bool)
func (c Container) SetAllowSpend(allow bool)

[server] Direct edits, outside transactions: set a slot, clear, resize, and allow collecting / spending.

func (c Container) SetFilters(allowed []Uuid)

[server] Only these items may be put in (empty: anything).

func (c Container) OnTransaction(fn func())

[server] Runs after every transaction that changed this container.

type World struct{ atl.Object }

A world: terrain, cells and everything in them (Lua World).

Methods

func (w World) ID() int

The world's id.

func (w World) IsIndoor() bool

True for an indoor world.

func (w World) Destroy()

[server] Destroys the world.

func (w World) CellBounds() CellBounds

Reads the world's cell bounds.

func (w World) IsCellInBounds(x, y int) bool

True if the cell is inside the bounds.

func (w World) IsCellLoadedServer(x, y int) bool

[server] True if the cell is loaded on the server.

func (w World) IsCellLoadedClient(x, y int) bool

[client] True if the cell is loaded on this client.

func (w World) LoadCell(x, y int, player Player, onLoaded func(x, y int))

[server] Loads a cell until player (if any) steps into it; onLoaded(x, y) runs when it's ready.

func (w World) LoadCellWithHandle(x, y int, onLoaded func(x, y int)) LoadCellHandle

Keeps a cell loaded until the handle is released (or garbage collected).

func (w World) LoadNavMeshWithHandle(x, y int, onLoaded func(x, y int)) LoadCellHandle

[server] Same, with its nav mesh.

func (w World) ReloadCell(x, y int, onDone func(x, y int, reloaded bool))

Reloads a cell. onDone(x, y, reloaded) gets false if the cell wasn't active.

func (w World) SetTerrainScriptData(data atl.Value)

Data for the terrain generation script (Create's data).

func (w World) ZoneID(position Vec3) atl.Value

The zone id at a position (nil if none).

func (w World) SetLightColorOverride(c Color)

[server] Overrides every light controller's color in the world.

func (w World) ClearLightColorOverride()

[server] Removes the light color override.

func (w World) DominantMaterialInSphere(position Vec3, radius float64) VoxelMaterial
func (w World) DominantMaterialInCapsule(position Vec3, radius, height float64) VoxelMaterial

The most common voxel material in a sphere / capsule.

func (w World) VoxelMaterialAt(worldPosition Vec3) VoxelMaterial

The voxel material at a point.

func (w World) WeightedVoxelDensityAt(point Vec3) WeightedDensity

Reads the interpolated voxel density at a point.

func (w World) IsVoxelTerrainPointClear(referencePosition, testPosition Vec3) bool

True if testPosition is free of voxel terrain, as seen from referencePosition.

func (w World) SphereVoxelDensityAddition(position Vec3, radius float64, material int, player Player)

[server] Adds voxels in a sphere.

func (w World) SphereVoxelDensitySubtraction(position Vec3, radius float64, filter *int, strength *float64,
onDone func(data atl.Value))

[server] Removes voxels in a sphere. filter is sm.world.voxelFilter; onDone(data) gets { remDensities, avgPositions }.

func (w World) VoxelDensityAddition(position, surfaceNormal Vec3, maxDistance float64, targetDensity, material int,
filter *int, player Player)

[server] Adds voxels along surfaceNormal up to maxDistance.

func (w World) VoxelDensitySubtraction(position, direction Vec3, radius float64, targetDensity int, filter *int,
destructionEffect bool, onDone func(data atl.Value))

[server] Removes voxels around the line position + direction within radius.

func (w World) VoxelDensitySubtractionPerMaterial(position, direction Vec3, radius float64, targetDensities []int,
filter *int, destructionEffect bool, onDone func(data atl.Value))

[server] Same, with a target density per material.

func (w World) SetMiningConfig(config atl.Value)

[server] Mining loot config (see WorldClass.ServerOnMining).

type CellBounds struct {
MinX, MaxX, MinY, MaxY int
}

The range of cell coordinates the world covers.

type VoxelMaterial struct {
Material int
Density int
Position Vec3
}

A voxel material and density, and (for dominant material queries) a position.

type WeightedDensity struct {
Density float64
Gradient Vec3
}

Voxel density and its gradient at a point.

type Harvestable struct{ atl.Object }

A tree, rock, plant or kinematic object (Lua Harvestable).

Methods

func (h Harvestable) ID() int

The harvestable's id.

func (h Harvestable) Uuid() Uuid
func (h Harvestable) Name() string
func (h Harvestable) Type() string

Its item uuid, name and type.

func (h Harvestable) Position() Vec3
func (h Harvestable) Rotation() Quat
func (h Harvestable) Scale() Vec3

Position, rotation and scale.

func (h Harvestable) Color() Color

Color.

func (h Harvestable) SetColor(c Color)

Paints the harvestable.

func (h Harvestable) Destroy()

[server] Destroys the harvestable.

func (h Harvestable) World() World

The world it's in.

func (h Harvestable) SetPosition(p Vec3)
func (h Harvestable) SetRotation(q Quat)

Moves / rotates a kinematic harvestable.

func (h Harvestable) Velocity() Vec3
func (h Harvestable) AngularVelocity() Vec3

Velocity and angular velocity.

func (h Harvestable) Mass() float64

Mass in kilograms.

func (h Harvestable) Material() string
func (h Harvestable) MaterialID() int

The physics material name and id.

func (h Harvestable) Aabb() Aabb
func (h Harvestable) LocalAabb() Aabb

World-space / local-space bounds.

func (h Harvestable) TransformPoint(worldPoint Vec3) Vec3
func (h Harvestable) TransformLocalPoint(localPoint Vec3) Vec3
func (h Harvestable) TransformDirection(worldDir Vec3) Vec3

World point to local / local point to world / world direction to local.

func (h Harvestable) IsKinematic() bool

True for a kinematic (scripted, movable) harvestable.

func (h Harvestable) IsCellKinematic() bool

True for a kinematic placed by a cell (vs. created from a script).

func (h Harvestable) InitialHash() float64

Identifies a kinematic across reloads (harvestables.ByInitialHash).

func (h Harvestable) Data() atl.Value

The script data from the harvestable's definition.

func (h Harvestable) SetParams(data atl.Value)

[server] Sets the params of a harvestable created from a script.

func (h Harvestable) PublicData() atl.Value

[server] Data other scripts can read.

func (h Harvestable) SetPublicData(t atl.Value)

[server] Sets data other scripts can read.

func (h Harvestable) ClientPublicData() atl.Value

[client] Data other client scripts can read.

func (h Harvestable) SetClientPublicData(t atl.Value)

[client] Sets data other client scripts can read.

func (h Harvestable) HasSeat() bool
func (h Harvestable) SeatCharacter() Character
func (h Harvestable) SetSeatCharacter(c Character)

Seats (kinematics with a seat component): whether there is one, who sits in it, and seating a character.

func (h Harvestable) ApplyShakeImpulse(shake float64)

[client] Shakes the harvestable visually.

func (h Harvestable) UvFrameIndex() int
func (h Harvestable) SetUvFrameIndex(index int)

[client] Reads / writes the UV frame.

func (h Harvestable) PoseWeight(index int) float64
func (h Harvestable) SetPoseWeight(index int, weight float64)

[client] Reads / writes an animation pose weight.

func (h Harvestable) SetSubMeshVisible(name string, visible bool)
func (h Harvestable) SetAllSubMeshVisible(visible bool)

[client] Shows or hides one / every sub-mesh.

type Network struct{ atl.Object }

A script's network channel between its server and client sides (self.network).

Methods

func (n Network) SendToServer(method string, data any)

[client] Calls method(data, sender) on the server side.

func (n Network) SendToClients(method string, data any)

[server] Calls method(data) on every client.

func (n Network) SendToClient(player Player, method string, data any)

[server] Calls method(data) on one player's client.

func (n Network) SetClientData(data any, channel int)

[server] Syncs data to ClientOnClientDataUpdate on every client, including players who join later.

type Effect struct{ atl.Object }

A visual or sound effect (Lua Effect).

Methods

func (e Effect) Start()

Starts playing.

func (e Effect) Stop()
func (e Effect) StopImmediate()

Stops, letting the effect finish / stops at once.

func (e Effect) Destroy()

Destroys the effect.

func (e Effect) IsPlaying() bool

True while playing.

func (e Effect) IsDone() bool

True once finished.

func (e Effect) SetPosition(p Vec3)
func (e Effect) SetRotation(q Quat)
func (e Effect) SetVelocity(v Vec3)
func (e Effect) SetScale(s Vec3)

Sets position, rotation, velocity and scale.

func (e Effect) SetOffsetPosition(p Vec3)
func (e Effect) SetOffsetRotation(q Quat)

Offset from the host.

func (e Effect) SetParameter(name string, value any)

Sets an effect parameter.

func (e Effect) SetAutoPlay(on bool)

Whether the effect restarts by itself when done.

func (e Effect) ID() int

The effect's id.

func (e Effect) WorldPosition() Vec3

[client] The effect's position in the world.

func (e Effect) SetStartStopDistance(startDistance, stopDistance float64)

Starts when the camera is within startDistance, stops beyond stopDistance.

func (e Effect) SetHost(host atl.Wrapper, bone string)

[client] Attaches to a Shape, Interactable, Character or Harvestable, optionally to a bone.

func (e Effect) HasHost() bool

[client] True if attached to a host.

func (e Effect) Detach()

[client] Detaches from the host.

func (e Effect) SetDetachOnHostDestroy(detach bool)

[client] Whether to detach instead of being destroyed with the host.

func (e Effect) SetHostAxisIgnore(axis int)

[client] A rotation axis (sm.effect.axis...) that hosted effects ignore.

func (e Effect) SetWorld(w World)

[client] The world the effect plays in.

func (e Effect) SetWorldAny()

[client] Plays in every world, for global sounds.

func (e Effect) SetTimeOfDay(enabled bool, startTime, endTime float64, inverse bool)

[client] Only active between startTime and endTime (0..1 time of day), or outside it if inverse.

func (e Effect) IsBreakSustaining() bool
func (e Effect) StopBreakSustain()

[client] Sustained sounds: whether the sound is finishing, and letting it finish before it's destroyed.

func (e Effect) HasActiveCamera() bool

[client] True while the effect controls the camera.

func (e Effect) CameraData() CameraData

[client] Reads the effect's camera.

func (e Effect) BindEventClientCallback(params, reference atl.Value)
func (e Effect) BindEventServerCallback(params, reference atl.Value)

[client] Effect event callbacks: reference is the script table that receives them (nil: the running script), params is passed through.

func (e Effect) ClearClientEventCallback()
func (e Effect) ClearServerEventCallback()

Removes the client / server event callbacks.

type CameraData struct {
Active, HasBlendIn, HasBlendOut bool
Position Vec3
Rotation Quat
Fov float64
}

[client] The camera an effect controls (camera effects).

type Tool struct{ atl.Object }

A tool a player holds (Lua Tool).

Methods

func (t Tool) ID() int

The tool's id.

func (t Tool) Uuid() Uuid

The tool's item uuid.

func (t Tool) Owner() Player

The player holding it.

func (t Tool) IsLocal() bool

True on the owner's client.

func (t Tool) IsEquipped() bool

True while equipped.

func (t Tool) IsInFirstPersonView() bool
func (t Tool) IsCrouching() bool
func (t Tool) IsSprinting() bool
func (t Tool) IsOnGround() bool

The owner's view and movement state.

func (t Tool) Position() Vec3
func (t Tool) Direction() Vec3

Position and aim direction of the tool.

func (t Tool) SmoothDirection() Vec3

Aim direction, smoothed.

func (t Tool) MovementVelocity() Vec3

The owner's movement velocity.

func (t Tool) MovementSpeedFraction() float64

The owner's movement speed scale.

func (t Tool) SetFpRenderables(rends []string)
func (t Tool) SetTpRenderables(rends []string)
func (t Tool) SetFpColor(c Color)
func (t Tool) SetTpColor(c Color)

[client] Sets the first / third person renderables (paths to .rend files) and their colors.

func (t Tool) UpdateAnimation(name string, time float64, weight *float64)

[client] Plays a third person animation; time is seconds into it.

func (t Tool) UpdateFpAnimation(name string, time float64, weight *float64, looping bool)

[client] Plays a first person animation.

func (t Tool) SetMovementAnimation(movement, animation string)

[client] Replaces a movement animation (e.g. "idle") with one of the tool's.

func (t Tool) SetMovementSlowDown(slowDown bool)

[client] Slows the owner down while held.

func (t Tool) SetBlockSprint(block bool)

[client] Prevents sprinting while held.

func (t Tool) SetCrossHairAlpha(alpha float64)
func (t Tool) SetCrossHairColor(c Color)
func (t Tool) SetCrossHairType(typ int)
func (t Tool) SetDispersionFraction(dispersion float64)

[client] Crosshair alpha, color, type and spread.

func (t Tool) UpdateCamera(distance, fov float64, offset Vec3, weight float64)

[client] Blends the camera toward a tool-specific view (aiming, ...).

func (t Tool) FpBonePosition(bone string) Vec3
func (t Tool) TpBonePosition(bone string) Vec3

[client] A bone's first / third person position.

func (t Tool) FpBoneDirection(bone string, worldSpace bool) Vec3
func (t Tool) FpBoneRotation(bone string, worldSpace bool) Quat
func (t Tool) TpBoneDirection(bone string) Vec3
func (t Tool) TpBoneRotation(bone string) Quat

[client] Bones: first-person local (or world) space, third-person world space.

func (t Tool) UpdateJoint(bone string, rotation Vec3, weight *float64)

[client] Rotates a bone of the animation skeleton.

func (t Tool) AnimationInfo(name string) AnimationInfo

[client] Information about a third person animation.

func (t Tool) FpAnimationInfo(name string) AnimationInfo

[client] Information about a first person animation.

func (t Tool) UpdateMovementAnimation(time float64, weight *float64)

[client] Advances the movement animation set with SetMovementAnimation.

func (t Tool) RelativeMoveDirection() Vec3

[client] Movement direction relative to where the player looks.

func (t Tool) UpdateFpCamera(fov float64, offset Vec3, weight, bobbing float64)

[client] Blends the first person camera toward a tool-specific view.

func (t Tool) CameraWeights() CameraWeights

[client] Current weights of the tool's camera settings (UpdateCamera / UpdateFpCamera).

type CameraWeights struct {
ThirdPerson, FirstPerson float64
}

Weights of the third / first person camera settings.

type LoadCellHandle struct{ atl.Object }

The handle from World.LoadCellWithHandle; the cell stays loaded until released.

Methods

func (h LoadCellHandle) Release() bool

[server] Releases the cell; returns true if it was held.

type Lift struct{ atl.Object }

A player's or non-player lift (Lua Lift).

Methods

func (l Lift) ID() int

The lift's id.

func (l Lift) Level() int

Its height level.

func (l Lift) WorldPosition() Vec3

Its position.

func (l Lift) HasBodies() bool

True if it carries bodies.

func (l Lift) Destroy()

[server] Removes the lift.

type Portal struct{ atl.Object }

A two-opening portal between (or within) worlds. All [server].

Methods

func (p Portal) ID() int

The portal's id.

func (p Portal) HasOpeningA() bool
func (p Portal) HasOpeningB() bool

[server] True if opening A / B is placed.

func (p Portal) SetOpeningA(position Vec3, rotation Quat, world World)
func (p Portal) SetOpeningB(position Vec3, rotation Quat, world World)

[server] Places opening A / B.

func (p Portal) PositionA() Vec3
func (p Portal) PositionB() Vec3
func (p Portal) RotationA() Quat
func (p Portal) RotationB() Quat
func (p Portal) WorldA() World
func (p Portal) WorldB() World

[server] Positions, rotations and worlds of the two openings.

func (p Portal) ContentsA() []Target
func (p Portal) ContentsB() []Target

[server] Characters and bodies in each opening.

func (p Portal) TransferAToB(filter *int) bool
func (p Portal) TransferBToA(filter *int) bool

[server] Moves what's in one opening to the other (filter: sm.areaTrigger.filter).

func (p Portal) SetAMarkerOffset(offset Vec3)
func (p Portal) SetBMarkerOffset(offset Vec3)
func (p Portal) SetAToBMarkerAllowed(allowed bool)
func (p Portal) SetBToAMarkerAllowed(allowed bool)

[server] Map markers: offsets, and whether each direction shows one.

type Storage struct{ atl.Object }

Server-side save data of a script (ScriptClass.Storage()). All [server].

Methods

func (s Storage) Load() atl.Value

[server] The saved data, or nil.

func (s Storage) Save(data any)

[server] Saves data for the next time the object loads.

type Target struct{ atl.Object }

A value that may be one of several object types (a collision's "other", a projectile's shooter, ...). Test with TargetIs, convert with TargetAs.

Methods

func (t Target) Kind() string

Lua's type(): "Shape", "Character", "Player", "Harvestable", "Unit", ...

type Typed interface {
atl.Wrapper
// contains filtered or unexported methods
}

The object types a Target can be tested for, by their Lua type() name.

type Unit struct{ atl.Object }

The AI driving a creature (Lua Unit). Most calls are [server].

Methods

func (u Unit) ID() int

[server] The unit's id.

func (u Unit) Character() Character

[server] The character it controls.

func (u Unit) FacingDirection() Vec3
func (u Unit) MovementDirection() Vec3

[server] The current facing / movement direction.

func (u Unit) SetFacingDirection(d Vec3)
func (u Unit) SetMovementDirection(d Vec3)

[server] Sets the direction to face / move in.

func (u Unit) SetMovementType(typ string)

[server] Sets how to move: "stand", "walk", "sprint", "crouch", ...

func (u Unit) SetWantsJump(jump bool)
func (u Unit) SetWantsCrouch(crouch bool)

[server] Requests a jump / crouch.

func (u Unit) SetWhiskerData(count int, maxAngle, startLength, endLength float64)

[server] Configures the obstacle-sensing rays used for movement.

func (u Unit) SetHearingData(noiseScale float64)

[server] Scales how well the unit hears noise.

func (u Unit) SendCharacterEvent(event string)

[server] Fires ClientOnEvent on the unit's character.

func (u Unit) PublicData() atl.Value
func (u Unit) SetPublicData(t atl.Value)

[server] Data other scripts can read, and setting it.

func (u Unit) Container(index int) Container

A container of the unit by index.

func (u Unit) AddContainer(index, size int, stackSize *int) Container

[server] Adds a container of size slots.

func (u Unit) RemoveContainer(index int)

[server] Removes a container.

func (u Unit) CreateState(name string) AiState

[server] Creates a built-in AI behaviour by name (see AiState).

func (u Unit) Destroy()

[server] Destroys the unit.

type AiState struct{ atl.Object }

A built-in AI behaviour from Unit.CreateState. Drive it from ServerOnUnitUpdate. All [server].

Methods

func (a AiState) Start()
func (a AiState) Stop()

[server] Starts / stops the behaviour.

func (a AiState) OnFixedUpdate(dt float64)
func (a AiState) OnUnitUpdate(dt float64)

[server] Advances the behaviour; call from the matching unit callback.

func (a AiState) IsDone() AiStateDone

[server] Whether it's done, and why (e.g. "finished" / "failed").

func (a AiState) FacingDirection() Vec3
func (a AiState) MovementDirection() Vec3
func (a AiState) MovementType() string
func (a AiState) WantsJump() bool
func (a AiState) WantsCrouch() bool

[server] What the state wants the unit to do; apply it with the Unit setters.

type AiStateDone struct {
Done bool
Reason string
}

Whether the behaviour has finished, and why.

type PathNode struct{ atl.Object }

A navigation node for sm.pathfinder (pathnodes.Create). All [server].

Methods

func (p PathNode) Position() Vec3

[server] The node's position.

func (p PathNode) Connect(to PathNode)

[server] Links this node to another.

func (p PathNode) Destroy()

[server] Removes the node.

type ScriptableObject struct{ atl.Object }

A scriptable object: a script with no body in the world (Lua ScriptableObject).

Methods

func (s ScriptableObject) ID() int

The object's id.

func (s ScriptableObject) World() World

The world it's in.

func (s ScriptableObject) Data() atl.Value

The params it was created with.

func (s ScriptableObject) PublicData() atl.Value

[server] Data other server scripts can read.

func (s ScriptableObject) SetPublicData(t atl.Value)

[server] Sets data other server scripts can read.

func (s ScriptableObject) ClientPublicData() atl.Value

[client] Data other client scripts can read.

func (s ScriptableObject) SetClientPublicData(t atl.Value)

[client] Sets data other client scripts can read.

func (s ScriptableObject) Destroy()

[server] Destroys the object.

type ClientScriptableObject struct{ atl.Object }

A scriptable object that only exists on one client (clientscriptableobjects.Create). All [client].

Methods

func (s ClientScriptableObject) ID() int

The object's id.

func (s ClientScriptableObject) World() World

The world it's in.

func (s ClientScriptableObject) Data() atl.Value

The params it was created with.

func (s ClientScriptableObject) ClientPublicData() atl.Value
func (s ClientScriptableObject) SetClientPublicData(t atl.Value)

Data other client scripts can read, and setting it.

func (s ClientScriptableObject) Destroy()

Destroys the object.

type ProjectileHit struct {
Position Vec3
AirTime float64
Velocity Vec3
Projectile string
Shooter Target
Damage int
CustomData atl.Value
Normal Vec3
Uuid Uuid
Mass float64
}

A projectile hit, as passed to *OnProjectile callbacks.

func ProjectileHitFromArgs(a atl.Value, i int) ProjectileHit

Builds the struct from callback arguments starting at index i.

type MeleeHit struct {
Position Vec3
Attacker Target
Damage int
Power float64
Direction Vec3
Normal Vec3
}

A melee hit, as passed to *OnMelee callbacks.

func MeleeHitFromArgs(a atl.Value, i int) MeleeHit

Builds the struct from callback arguments starting at index i.

type CollisionHit struct {
Other Target
Position Vec3
SelfPointVelocity Vec3
OtherPointVelocity Vec3
Normal Vec3
}

A collision, as passed to *OnCollision callbacks.

func CollisionHitFromArgs(a atl.Value, i int) CollisionHit

Builds the struct from callback arguments starting at index i.

type WorldProjectileHit struct {
ProjectileHit
Target Target
}

A projectile hit as passed to WorldClass callbacks, with the object that was hit.

func WorldProjectileHitFromArgs(a atl.Value, i int) WorldProjectileHit

Builds the struct from callback arguments starting at index i (server calls carry CustomData).

type WorldMeleeHit struct {
MeleeHit
Target Target
}

A melee hit as passed to WorldClass callbacks, with the object that was hit.

func WorldMeleeHitFromArgs(a atl.Value, i int) WorldMeleeHit

Builds the struct from callback arguments starting at index i.

type WorldCollision struct {
A, B Target
Position Vec3
PointVelocityA, PointVelocityB Vec3
Normal Vec3
}

A collision between two objects, as passed to WorldClass callbacks.

func WorldCollisionFromArgs(v atl.Value, i int) WorldCollision

Builds the struct from callback arguments starting at index i.

type AreaTrigger struct {
atl.Object
// contains filtered or unexported fields
}

A trigger volume. Triggers created through atl/sm/areatrigger are destroyed with the script that created them, along with their callbacks. A tracked AreaTrigger stays valid across callbacks, so it can be stored in a field.

func NewAreaTrigger(v atl.Value) AreaTrigger

Wraps an existing Lua trigger.

func TrackTrigger(v atl.Value) AreaTrigger

Wraps a Lua trigger so it's destroyed with the current script.

Methods

func (t *AreaTrigger) ID() int

The trigger's id.

func (t *AreaTrigger) WorldPosition() Vec3
func (t *AreaTrigger) WorldRotation() Quat
func (t *AreaTrigger) SetWorldPosition(p Vec3)
func (t *AreaTrigger) SetWorldRotation(q Quat)

Position and rotation in the world.

func (t *AreaTrigger) Size() Vec3
func (t *AreaTrigger) SetSize(s Vec3)

Size of the volume (box extents, or radius and length for spheres and cylinders).

func (t *AreaTrigger) WorldBounds() Aabb

The world-space bounding box.

func (t *AreaTrigger) World() World

The world the trigger is in.

func (t *AreaTrigger) UserData() atl.Value

The user data passed at creation.

func (t *AreaTrigger) HostInteractable() Interactable

The interactable the trigger is attached to, if any.

func (t *AreaTrigger) Contents() []Target

Everything currently inside.

func (t *AreaTrigger) Shapes() []Shape
func (t *AreaTrigger) Characters() []Character
func (t *AreaTrigger) Harvestables() []Harvestable

Only the shapes, characters or harvestables inside.

func (t *AreaTrigger) SetShapeDetection(on bool)
func (t *AreaTrigger) SetCharacterDetection(on bool)
func (t *AreaTrigger) SetHarvestableDetection(on bool)

Chooses which kinds of object the trigger detects.

func (t *AreaTrigger) SetIncludeShapesInContent(on bool)

Whether Contents() lists shapes individually.

func (t *AreaTrigger) Destroy()

Destroys the trigger and frees its callbacks.

func (t *AreaTrigger) OnEnter(fn func(objects []Target)) *AreaTrigger
func (t *AreaTrigger) OnExit(fn func(objects []Target)) *AreaTrigger
func (t *AreaTrigger) OnStay(fn func(objects []Target)) *AreaTrigger

Called with the objects that entered, left, or stayed inside this tick.

func (t *AreaTrigger) OnProjectile(fn func(hit ProjectileHit)) *AreaTrigger

Called when a projectile hits the trigger.

func (t *AreaTrigger) OnMelee(fn func(hit MeleeHit)) *AreaTrigger

Called when a melee attack hits the trigger.

func (t *AreaTrigger) OnInteract(fn func(character Character, pressed bool)) *AreaTrigger

Called when a character interacts with the trigger.

func (t *AreaTrigger) CanInteract(fn func(character Character) bool) *AreaTrigger

Decides whether a character may interact with the trigger.

func (t *AreaTrigger) OnDestroy(fn func()) *AreaTrigger

Called when the trigger is destroyed.

func (t *AreaTrigger) OnHostDestroy(fn func()) *AreaTrigger
func (t *AreaTrigger) OnHostUnload(fn func()) *AreaTrigger

Called when the object the trigger is attached to is destroyed / unloaded (host only).

func (t *AreaTrigger) CanErase(fn func() bool) *AreaTrigger
func (t *AreaTrigger) OnErase(fn func()) *AreaTrigger

[client] For erasable triggers: decides whether erasing is allowed, and is told when it happens.

func (t *AreaTrigger) SetEraseTime(seconds float64)
func (t *AreaTrigger) SetDestroyOnErase(destroy bool)

How long erasing takes, and whether erasing destroys the trigger.

func (t *AreaTrigger) SetWaterType(liquidType int)

Makes the trigger a liquid (sm.areaTrigger.liquidType).

func (t *AreaTrigger) HasVoxelTerrainContact() bool

True when touching voxel terrain.

func (t *AreaTrigger) SetVoxelDestructible(destructible bool)

Whether the trigger can destroy voxel terrain.

type Garage struct{ atl.Object }

A blueprint import area, like the survival garage.

Methods

func (g Garage) Position() Vec3

The garage's position.

func (g Garage) Bounds() Aabb

The garage's bounds.

func (g Garage) HasActiveTracking() bool

True while a blueprint is tracked.

func (g Garage) TrackingRevision() int

Changes each time the tracked blueprint changes.

func (g Garage) TrackBlueprint(path string)

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

func (g Garage) UntrackBlueprint()

Stops tracking.

func (g Garage) TrackedBlueprint() GarageBlueprint

Reads the tracked blueprint.

func (g Garage) BlueprintBounds() Aabb

The tracked blueprint's bounds.

func (g Garage) CreationFits() *bool

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

func (g Garage) Placement() *Vec3

Where the creation would be placed.

func (g Garage) ImportBlueprint()

Imports the tracked blueprint.

type GarageBlueprint struct {
Name string
Json atl.Value
}

The tracked blueprint's name and contents.