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.
Constants
Section titled "Constants"const PI = 3.14159265358979323846Pi.
const DEG = PI / 180.0Degrees to radians: 90 * sm.DEG.
const HalfSqrt2 = 0.70710678118654752440Fixed 90 and 180 degree rotations (sm.quat.rotX90() and so on).
const NetworkPacketLimit = sys.NetworkPacketLimitThe 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.
Functions
Section titled "Functions"func Sqrt(x float64) float64Square root.
func Abs(x float64) float64Absolute value.
func Sin(x float64) float64func Cos(x float64) float64func Tan(x float64) float64func Asin(x float64) float64func Acos(x float64) float64func Atan2(y, x float64) float64func Pow(x, y float64) float64Trigonometry and pow, computed by Lua's math library.
func Floor(x float64) float64func Ceil(x float64) float64Rounds down / up to a whole number.
func Clamp(x, lo, hi float64) float64x limited to the range lo..hi.
func Lerp(a, b, t float64) float64Linear interpolation from a (t = 0) to b (t = 1).
func At[T any](r []atl.Value, i int) TResult i of r converted to T, or T's zero value when there are fewer results.
func BindCallback(fn func(args atl.Value)) stringFor 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) boolTrue if the value is a T.
func TargetAs[T any](t Target) TThe value as a T.
func IsServer() boolTrue when running on the server side.
func IsHost() boolTrue when this game instance hosts the session.
GuiOptions
Section titled "GuiOptions"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) GuiWraps 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) GuiTakes 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() boolTrue 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() Vec3For 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()) *GuiCalled when a button is clicked.
func (g *Gui) OnTextChanged(editBox string, fn func(text string)) *GuiCalled with an edit box's text whenever it changes.
func (g *Gui) OnTextAccepted(editBox string, fn func(text string)) *GuiCalled with an edit box's text when Enter is pressed.
func (g *Gui) OnSlider(slider string, fn func(position int)) *GuiCalled with a slider's new position.
func (g *Gui) HorizontalSlider(widget string, rng, value int, fn func(position int), numbered bool) *Guifunc (g *Gui) VerticalSlider(widget string, rng, value int, fn func(position int)) *GuiTurns a widget into a horizontal / vertical slider, called with its new position.
func (g *Gui) DropDown(widget string, options []string, fn func(option string)) *GuiTurns a widget into a drop-down, called with the selected option.
func (g *Gui) OnGridButton(button string, fn func(index int, item atl.Value)) *GuiCalled 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)) *GuiCalled with the index and item data when a grid item is clicked.
func (g *Gui) OnListSelection(list string, fn func(args atl.Value)) *GuiCalled when a list item is selected (engine-defined arguments).
func (g *Gui) OnOpen(fn func()) *GuiCalled when the GUI opens.
func (g *Gui) OnClose(fn func()) *GuiCalled when the GUI closes.
func (g *Gui) ClearOnClose() *GuiRemoves the OnClose handler (a destroyOnClose GUI is still cleaned up when it closes).
func (g *Gui) OnGridItemChanged(grid string, fn func(args atl.Value)) *GuiCalled when a grid item changes (engine-defined arguments, e.g. grid, index, item).
func (g *Gui) OnGridMouseFocus(button string, fn func(args atl.Value)) *GuiCalled when the mouse enters or leaves a grid item (engine-defined arguments).
func (g *Gui) OnDressbotUnlock(fn func(item Uuid)) *GuiFor dress bot GUIs: called with the unlocked customization item.
GridSpec
Section titled "GridSpec"type GridSpec struct { Type string Layout string ItemWidth, ItemHeight, ItemCount int}Describes a grid for CreateGrid.
QuestTask
Section titled "QuestTask"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() Vec3func Vec3One() Vec3(0, 0, 0) and (1, 1, 1).
func Vec3Bezier2(c0, c1, c2 Vec3, t float64) Vec3Point on a quadratic Bezier curve at t (0..1).
func Vec3Bezier3(c0, c1, c2, c3 Vec3, t float64) Vec3Point on a cubic Bezier curve at t (0..1).
Methods
func (v Vec3) Add(o Vec3) Vec3func (v Vec3) Sub(o Vec3) Vec3func (v Vec3) Mul(o Vec3) Vec3func (v Vec3) Div(o Vec3) Vec3func (v Vec3) Scale(s float64) Vec3func (v Vec3) DivS(s float64) Vec3func (v Vec3) Neg() Vec3Component-wise arithmetic, and scaling by a number.
func (v Vec3) Dot(o Vec3) float64Dot product.
func (v Vec3) Cross(o Vec3) Vec3Cross product.
func (v Vec3) Length2() float64Squared length (cheaper than Length()).
func (v Vec3) Length() float64Length.
func (v Vec3) Distance(o Vec3) float64Distance to another point.
func (v Vec3) Normalize() Vec3Unit vector in the same direction; a zero vector stays zero.
func (v Vec3) Distance2(o Vec3) float64Squared distance to another point.
func (v Vec3) SafeNormalize(fallback Vec3) Vec3Unit vector in the same direction, or fallback for a zero vector.
func (v Vec3) Lerp(to Vec3, t float64) Vec3Linear interpolation towards to.
func (v Vec3) FuzzyEquals(o Vec3, eps float64) boolTrue when the two vectors are within eps of each other.
func (v Vec3) Abs() Vec3func (v Vec3) Floor() Vec3func (v Vec3) Ceil() Vec3Component-wise absolute value, floor and ceil.
func (v Vec3) Min(o Vec3) Vec3func (v Vec3) Max(o Vec3) Vec3Component-wise minimum and maximum.
func (v Vec3) Rotate(radians float64, axis Vec3) Vec3This vector rotated radians around axis (same convention as QuatAngleAxis).
func (v Vec3) RotateX(radians float64) Vec3func (v Vec3) RotateY(radians float64) Vec3func (v Vec3) RotateZ(radians float64) Vec3Rotation around a world axis.
func (v Vec3) ClosestAxis() Vec3The axis-aligned unit vector closest to this direction.
func (v Vec3) String() stringText forms for Format and logging.
func (v Vec3) IntoLua() atl.Valuefunc (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() uint32Vec3, 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() QuatNo rotation.
func QuatAngleAxis(radians float64, axis Vec3) QuatA rotation of radians around axis.
func QuatFromEuler(degrees Vec3) QuatA rotation from Euler angles in degrees (sm.quat.fromEuler).
func QuatLookRotation(at, up Vec3) QuatA rotation facing at with up as up (sm.quat.lookRotation).
func QuatFromTo(from, to Vec3) QuatThe shortest rotation taking direction from to direction to (sm.vec3.getRotation).
func QuatRotX90() Quatfunc QuatRotY90() Quatfunc QuatRotZ90() Quatfunc QuatRotNegX90() Quatfunc QuatRotNegY90() Quatfunc QuatRotNegZ90() Quatfunc QuatRotX180() Quatfunc QuatRotY180() Quatfunc QuatRotZ180() QuatMethods
func (q Quat) At() Vec3func (q Quat) Up() Vec3func (q Quat) Right() Vec3The rotated forward, up and right directions (Quat:getAt/getUp/getRight).
func (q Quat) Round90() QuatSnapped to the nearest 90 degree steps.
func (q Quat) SafeNormalize(fallback Quat) QuatNormalized, or fallback if the quaternion has zero length.
func (q Quat) Mul(o Quat) QuatCombines rotations: a.Mul(b) applies b, then a.
func (q Quat) Rotate(v Vec3) Vec3Rotates a vector.
func (q Quat) Inverse() QuatThe opposite rotation.
func (q Quat) Normalize() QuatUnit length; a zero quaternion becomes the identity.
func (q Quat) Slerp(to Quat, t float64) QuatSpherical interpolation towards to along the shortest path.
func (q Quat) String() stringfunc (q Quat) IntoLua() atl.Valuefunc (q *Quat) FromLua(x atl.Value)func (q Quat) WireEncode(w *wire.Writer)func (q *Quat) WireDecode(r *wire.Reader)func (Quat) WireSchema() uint32type Color struct { R, G, B, A float64}An RGBA color (sm.color) with channels from 0 to 1.
func White() ColorWhite.
func ColorRGB(hex uint32) ColorA color from 0xRRGGBB, e.g. sm.ColorRGB(0x4a90d9).
func ColorRGBA(hex uint32) ColorA color from 0xRRGGBBAA.
func ColorHex(s string) ColorA color from "#rrggbb", "rrggbb", "#rrggbbaa" or "rrggbbaa".
Methods
func (c Color) Lerp(to Color, t float64) ColorLinear 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() stringThe engine's GUI color string, as Color:getGuiColorStr().
func (c Color) UintRgba() uint320xRRGGBBAA, as Color:getUintRgba().
func (c Color) String() stringfunc (c Color) IntoLua() atl.Valuefunc (c *Color) FromLua(x atl.Value)func (c Color) WireEncode(w *wire.Writer)func (c *Color) WireDecode(r *wire.Reader)func (Color) WireSchema() uint32type Uuid [16]byteA uuid (sm.uuid), stored as its 16 bytes. The zero Uuid is the nil uuid.
func ParseUuid(s string) UuidParses the text form; missing or invalid characters become '0'.
func UuidRandom() UuidA random uuid.
func UuidNamed(ns Uuid, name string) UuidA version 5 uuid: the same name in the same ns always gives the same uuid.
Methods
func (u Uuid) IsNil() boolTrue for the nil uuid.
func (u Uuid) String() stringThe 36-character text.
func (u Uuid) IntoLua() atl.Valuefunc (u *Uuid) FromLua(x atl.Value)func (u Uuid) WireEncode(w *wire.Writer)func (u *Uuid) WireDecode(r *wire.Reader)func (Uuid) WireSchema() uint32BlueprintVisualization
Section titled "BlueprintVisualization"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.
CullSphereGroup
Section titled "CullSphereGroup"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) CullSphereDeltaSpheres that left outerRadius / entered innerRadius since the last call.
func (c CullSphereGroup) Overlaps(position Vec3, radius float64) []intIds of every sphere overlapping a sphere at position.
func (c CullSphereGroup) Leave() []intLeaves every active sphere, returning their ids.
CullSphereDelta
Section titled "CullSphereDelta"type CullSphereDelta struct { Removed, Added []int}Ids of the spheres that left and entered.
BuilderGuide
Section titled "BuilderGuide"type BuilderGuide struct{ atl.Object }Compares a creation against a blueprint, stage by stage.
Methods
func (b BuilderGuide) ID() intThe guide's id.
func (b BuilderGuide) CurrentStageIndex() intThe stage being built.
func (b BuilderGuide) IsComplete() boolTrue 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() BuilderGuideStageReads the current stage's progress.
func (b BuilderGuide) ErrorInfo() BuilderGuideErrorsReads the recorded mismatches (needs recordErrors).
BuilderGuideStage
Section titled "BuilderGuideStage"type BuilderGuideStage struct { BlocksLeft, PartsLeft, JointsLeft, ConnectionsLeft int}What remains to be built in the current stage.
BuilderGuideErrors
Section titled "BuilderGuideErrors"type BuilderGuideErrors struct { Blocks, Parts, Joints, Connections, ConnectionsReversed int}Counts of mismatches against the blueprint.
JsonWidget
Section titled "JsonWidget"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) stringfunc (w JsonWidget) SetUserString(key, value string)Reads / writes a string stored on the widget.
func (w JsonWidget) Effect(name string) EffectAn 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) boolfunc (w JsonWidget) IsEffectDone(name string) boolWhether an attached effect is playing / has finished.
JsonGui
Section titled "JsonGui"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) JsonWidgetA widget by name.
func (g JsonGui) WidgetAbsolutePosition(name string) JsonGuiPositionA widget's position on screen.
func (g JsonGui) IsActive() boolTrue while open.
func (g JsonGui) IsHidden() boolTrue 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.
JsonGuiPosition
Section titled "JsonGuiPosition"type JsonGuiPosition struct { Left, Top float64}A position in 720p units.
InputBlock
Section titled "InputBlock"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.ValueTool input blocking, returned to the engine as two values.
ScriptClass
Section titled "ScriptClass"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.ValueThe Lua script instance (self).
func (s *ScriptClass) Network() Networkself.network, for network calls between the server and client sides.
func (s *ScriptClass) Data() atl.Valueself.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.ValueCalls 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.
ScriptCallbacks
Section titled "ScriptCallbacks"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.
ShapeClass
Section titled "ShapeClass"type ShapeClass struct{ ScriptClass }A part or block script (scriptClass for a shape). Its callbacks are ShapeCallbacks.
Methods
func (s *ShapeClass) Shape() ShapeThe shape this script runs on.
func (s *ShapeClass) Interactable() InteractableThe shape's interactable.
ShapeCallbacks
Section titled "ShapeCallbacks"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.
ToolClass
Section titled "ToolClass"type ToolClass struct{ ScriptClass }A tool script. Its callbacks are ToolCallbacks.
Methods
func (s *ToolClass) Tool() ToolThe tool this script runs on.
func (s *ToolClass) Owner() PlayerThe player holding the tool.
func (s *ToolClass) IsLocal() boolTrue on the client of the player who owns the tool.
func (s *ToolClass) IsEquipped() boolTrue while the tool is equipped.
ToolCallbacks
Section titled "ToolCallbacks"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.
CharacterClass
Section titled "CharacterClass"type CharacterClass struct{ ScriptClass }A character script (scriptClass for a character type). Its callbacks are CharacterCallbacks.
Methods
func (s *CharacterClass) Character() CharacterThe character this script runs on.
CharacterCallbacks
Section titled "CharacterCallbacks"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.
HarvestableClass
Section titled "HarvestableClass"type HarvestableClass struct{ ScriptClass }A harvestable script (trees, rocks, crops...). Its callbacks are HarvestableCallbacks.
Methods
func (s *HarvestableClass) Harvestable() HarvestableThe harvestable this script runs on.
HarvestableCallbacks
Section titled "HarvestableCallbacks"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.
UnitClass
Section titled "UnitClass"type UnitClass struct{ ScriptClass }A unit script: the AI that controls a creature, server only. Its callbacks are UnitCallbacks.
Methods
func (s *UnitClass) Unit() UnitThe unit this script runs on.
UnitCallbacks
Section titled "UnitCallbacks"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.
PlayerClass
Section titled "PlayerClass"type PlayerClass struct{ ScriptClass }A player script (the game's player class). Its callbacks are PlayerCallbacks.
Methods
func (s *PlayerClass) Player() PlayerThe player this script runs on.
PlayerCallbacks
Section titled "PlayerCallbacks"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.
WorldClass
Section titled "WorldClass"type WorldClass struct{ ScriptClass }A world script. Its callbacks are WorldCallbacks.
Methods
func (s *WorldClass) World() WorldThe world this script runs on.
WorldCallbacks
Section titled "WorldCallbacks"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.
ScriptableObjectClass
Section titled "ScriptableObjectClass"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() ScriptableObjectThe scriptable object this script runs on.
func (s *ScriptableObjectClass) Params() atl.ValueThe params it was created with.
ScriptableObjectCallbacks
Section titled "ScriptableObjectCallbacks"type ScriptableObjectCallbacks interface { ScriptCallbacks // [server] Called when the object unloads. ServerOnUnload()}The callbacks a ScriptableObjectClass can define.
ClientScriptableObjectClass
Section titled "ClientScriptableObjectClass"type ClientScriptableObjectClass struct{ ScriptClass }A scriptable object that exists on one client only (clientscriptableobjects.Create). Its callbacks are ScriptCallbacks.
Methods
func (s *ClientScriptableObjectClass) ScriptableObject() ClientScriptableObjectThe scriptable object this script runs on.
func (s *ClientScriptableObjectClass) Params() atl.ValueThe params it was created with.
TerrainScript
Section titled "TerrainScript"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.
CullingZoneTree
Section titled "CullingZoneTree"type CullingZoneTree struct { Portals, Zones atl.Value}Culling portals and zones.
Methods
func (c CullingZoneTree) IntoLua() atl.ValueTerrainCallbacks
Section titled "TerrainCallbacks"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.
ChatParam
Section titled "ChatParam"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.
GameClass
Section titled "GameClass"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.
GameCallbacks
Section titled "GameCallbacks"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.
ServerNetwork
Section titled "ServerNetwork"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.
ClientNetwork
Section titled "ClientNetwork"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).
ScriptSide
Section titled "ScriptSide"type ScriptSide struct { // contains filtered or unexported fields}Base of both halves of a split script class.
Methods
func (s *ScriptSide) Self() atl.ValueThe Lua script instance (self).
func (s *ScriptSide) Data() atl.Valueself.data: the class's data from its JSON definition.
ServerShapeClass
Section titled "ServerShapeClass"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() ShapeThe shape this script runs on.
func (s *ServerShapeClass) Interactable() InteractableThe 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.
ServerShapeCallbacks
Section titled "ServerShapeCallbacks"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.
ClientShapeClass
Section titled "ClientShapeClass"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() ShapeThe shape this script runs on.
func (s *ClientShapeClass) Interactable() InteractableThe shape's interactable.
func (s *ClientShapeClass) Network() ClientNetworkThe network, for sending to the server half.
ClientShapeCallbacks
Section titled "ClientShapeCallbacks"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.
Method
Section titled "Method"type Method[T any] func(obj *T, args atl.Value) atl.ValueA 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.
ClassDef
Section titled "ClassDef"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)).
SideDef
Section titled "SideDef"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.
Handler
Section titled "Handler"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.
Sticky
Section titled "Sticky"type Sticky struct { Positive, Negative Vec3}The positive-xyz and negative-xyz sticky directions of a shape or joint.
TerrainColor
Section titled "TerrainColor"type TerrainColor struct { R, G, B float64}A terrain color (TerrainScript, terraintile).
Methods
func (c TerrainColor) IntoLua() atl.ValueMaterialWeights
Section titled "MaterialWeights"type MaterialWeights struct { Weights [8]float64}The 8 ground material weights at a terrain point.
Methods
func (m MaterialWeights) IntoLua() atl.ValueMineSpawn
Section titled "MineSpawn"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.
Destruction
Section titled "Destruction"type Destruction struct { AttackLevel int Type *int Position *Vec3 Normal *Vec3}How a shape is destroyed (Type is an sm.shape.destructionType value).
AnimationInfo
Section titled "AnimationInfo"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.
ActiveAnimation
Section titled "ActiveAnimation"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() intThe shape's unique id.
func (s Shape) Uuid() UuidThe shape's item uuid.
func (s Shape) Body() BodyThe body the shape belongs to.
func (s Shape) Interactable() InteractableThe shape's interactable, or empty for a plain block.
func (s Shape) WorldPosition() Vec3func (s Shape) WorldRotation() Quatfunc (s Shape) LocalPosition() Vec3func (s Shape) LocalRotation() QuatPosition and rotation in the world, and relative to the body.
func (s Shape) Velocity() Vec3Velocity in meters per second.
func (s Shape) At() Vec3func (s Shape) Up() Vec3func (s Shape) Right() Vec3The shape's forward (at), up and right directions in the world.
func (s Shape) XAxis() Vec3func (s Shape) YAxis() Vec3func (s Shape) ZAxis() Vec3The shape's local x, y and z axes in world space.
func (s Shape) BoundingBox() Vec3Size in blocks.
func (s Shape) LocalAabb() AabbThe bounding box in body-local coordinates.
func (s Shape) Mass() float64Mass in kilograms.
func (s Shape) Material() stringThe physics material name.
func (s Shape) Color() ColorThe paint color.
func (s Shape) SetColor(c Color)[server] Paints the shape.
func (s Shape) Burning() boolTrue 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) Vec3func (s Shape) TransformDirection(worldDir Vec3) Vec3World point / direction to shape-local.
func (s Shape) TransformLocalPoint(localPoint Vec3) Vec3func (s Shape) TransformLocalDirection(localDir Vec3) Vec3Shape-local point / direction to world.
func (s Shape) Joints(onlyChildJoints bool) []JointJoints 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() Vec3func (s Shape) InterpolatedAt() Vec3func (s Shape) InterpolatedUp() Vec3func (s Shape) InterpolatedRight() Vec3Positions and directions smoothed between physics ticks, for rendering.
func (s Shape) TransformRotation(worldRotation Quat) QuatA world rotation in shape-local terms.
func (s Shape) ClosestBlockLocalPosition(worldPosition Vec3) Vec3The local position of the shape's block nearest to a world position.
func (s Shape) Buoyancy() float64Buoyancy of the shape's material.
func (s Shape) MaterialID() intThe 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() boolTrue for a harvested item.
func (s Shape) IsStackable() boolTrue if the item stacks.
func (s Shape) Sticky() StickyThe sticky directions.
func (s Shape) Compromised() boolTrue 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() []Shapefunc (s Shape) MultiShapeJoints() []JointThe shapes and joints of the multi-shape item this shape belongs to.
func (s Shape) IsPipe() boolTrue for pipe parts.
func (s Shape) PipeOffsets(direction *int) []Vec3Pipe connection offsets, optionally for one direction only.
func (s Shape) PipedNeighbours() []Shape[server] Pipes connected to this one.
func (s Shape) OutputContainerIndex() intThe 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() intThe 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() WorldThe world the body is in.
func (b Body) WorldPosition() Vec3Position of the body's origin.
func (b Body) CenterOfMass() Vec3Center of mass in world space.
func (b Body) Velocity() Vec3func (b Body) AngularVelocity() Vec3Linear / angular velocity.
func (b Body) Mass() float64Mass in kilograms.
func (b Body) LocalAabb() Aabbfunc (b Body) WorldAabb() AabbBounding box in body-local / world coordinates.
func (b Body) Shapes() []Shapefunc (b Body) Interactables() []Interactablefunc (b Body) Joints() []JointThe body's shapes, interactables and joints.
func (b Body) CreationBodies() []Bodyfunc (b Body) CreationShapes() []Shapefunc (b Body) CreationJoints() []JointThe bodies, shapes and joints of the whole creation.
func (b Body) SeatedCharacters() []Character[server] Characters seated in the body.
func (b Body) ShapeCount() intNumber of shapes.
func (b Body) Shape(index int) ShapeShape by index.
func (b Body) ShapesByUuid(uuid Uuid) []ShapeShapes of one item type.
func (b Body) HasChanged(tick int) boolTrue if the body changed after tick (compare with game.CurrentTick()).
func (b Body) Lift() LiftThe lift the body is on (empty if none).
func (b Body) IsGhost() boolTrue for a ghost (non-colliding) body.
func (b Body) IsOnVirtualLift() boolTrue when held by a virtual lift.
func (b Body) IsConnectable() boolfunc (b Body) IsLiftable() boolfunc (b Body) IsConvertibleToDynamic() boolPermission 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() boolfunc (b Body) IsDynamic() boolTrue if the body is static / dynamic.
func (b Body) IsOnLift() boolTrue when on a lift.
func (b Body) IsBuildable() boolfunc (b Body) IsDestructable() boolfunc (b Body) IsErasable() boolfunc (b Body) IsPaintable() boolfunc (b Body) IsUsable() boolPermission 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) Vec3World point to body-local.
func (b Body) TransformLocalPoint(localPoint Vec3) Vec3Body-local point to world.
func (b Body) TransformWorldPoint(worldPoint Vec3) Vec3World 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.
Connection
Section titled "Connection"type Connection intConnection 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)Interactable
Section titled "Interactable"type Interactable struct{ atl.Object }The scripted, connectable side of a part (Lua Interactable).
Methods
func (i Interactable) ID() intThe interactable's id.
func (i Interactable) Shape() Shapefunc (i Interactable) Body() BodyThe shape and body it belongs to.
func (i Interactable) Type() stringThe interactable type, e.g. "engine".
func (i Interactable) IsActive() boolTrue when active (on).
func (i Interactable) SetActive(on bool)[server] Turns the interactable on or off.
func (i Interactable) Power() float64The output power value.
func (i Interactable) SetPower(p float64)[server] Sets the output power.
func (i Interactable) Parents(filter *Connection) []Interactablefunc (i Interactable) Children(filter *Connection) []InteractableInteractables connected as inputs / outputs, optionally of one connection type.
func (i Interactable) SingleParent() InteractableThe 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() boolTrue if the part has a seat.
func (i Interactable) SeatCharacter() CharacterThe 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) ContainerA 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() intfunc (i Interactable) MaxChildCount() intHow many parents / children may connect.
func (i Interactable) InputType() Connectionfunc (i Interactable) OutputType() ConnectionThe connection types accepted as input / produced as output.
func (i Interactable) HasOutputType(flags Connection) boolTrue if the output includes all of flags.
func (i Interactable) ConnectionColor() Colorfunc (i Interactable) ConnectionHighlightColor() ColorConnection colors (normal / highlighted).
func (i Interactable) Joints() []Jointfunc (i Interactable) Bearings() []Jointfunc (i Interactable) Pistons() []JointConnected 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.ValueData 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) boolTrue 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() []InteractableInteractables the seat controls (the hotbar of a seat).
func (i Interactable) PressSeatInteractable(index int) boolfunc (i Interactable) ReleaseSeatInteractable(index int) boolPresses / releases a seat hotbar slot.
func (i Interactable) HasSteering() boolTrue for a driver's seat with steering.
func (i Interactable) SteeringAngle() float64Steering input: A = -1, D = 1.
func (i Interactable) SteeringPower() float64Throttle input: W = 1, S = -1.
func (i Interactable) SteeringSprint() boolTrue 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) SteeringJointReads 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) float64func (i Interactable) SteeringJointRightAngleLimit(j Joint) float64func (i Interactable) SteeringJointLeftAngleSpeed(j Joint) float64func (i Interactable) SteeringJointRightAngleSpeed(j Joint) float64func (i Interactable) SteeringJointUnlocked(j Joint) boolRead 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() float64The current glow multiplier.
func (i Interactable) UvFrameIndex() int[client] The current UV frame.
func (i Interactable) PoseWeight(index int) float64func (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) Vec3func (i Interactable) WorldBonePosition(bone string) Vec3A bone's position, local / in the world.
SteeringJoint
Section titled "SteeringJoint"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() intThe joint's id.
func (j Joint) Type() stringThe joint type, e.g. "bearing" or "piston".
func (j Joint) ShapeA() ShapeThe shape the joint is placed on.
func (j Joint) ShapeB() ShapeThe shape on the joint's far side; empty when nothing is attached.
func (j Joint) Uuid() UuidThe joint's item uuid.
func (j Joint) WorldPosition() Vec3func (j Joint) WorldRotation() Quatfunc (j Joint) LocalPosition() Vec3func (j Joint) LocalRotation() QuatPosition and rotation, in the world / on the body.
func (j Joint) XAxis() Vec3func (j Joint) YAxis() Vec3func (j Joint) ZAxis() Vec3The joint's local axes in world space.
func (j Joint) BoundingBox() Vec3Size in blocks.
func (j Joint) Color() ColorPaint color.
func (j Joint) SetColor(c Color)[server] Paints the joint.
func (j Joint) Sticky() StickyThe sticky directions.
func (j Joint) MultiShapeShapes() []Shapefunc (j Joint) MultiShapeJoints() []JointThe shapes and joints of its multi-shape item.
func (j Joint) Angle() float64func (j Joint) AngularVelocity() float64A bearing's angle in radians and angular speed.
func (j Joint) AngularVelocityVector() Vec3Angular velocity as a vector.
func (j Joint) AppliedImpulse() float64The impulse the motor applied last tick.
func (j Joint) BearingEnabled() boolTrue if the bearing turns freely.
func (j Joint) Length() float64A piston's current length.
func (j Joint) IsReversed() boolTrue 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.
Character
Section titled "Character"type Character struct{ atl.Object }A character: a player's body or a creature (Lua Character).
Methods
func (c Character) ID() intThe character's id.
func (c Character) Player() PlayerThe controlling player; empty for non-player characters.
func (c Character) IsPlayer() boolTrue for a player's character.
func (c Character) World() WorldThe world the character is in.
func (c Character) WorldPosition() Vec3Position in the world.
func (c Character) SetWorldPosition(p Vec3)[server] Teleports the character.
func (c Character) Velocity() Vec3Velocity.
func (c Character) Direction() Vec3Look direction.
func (c Character) Mass() float64func (c Character) Height() float64func (c Character) Radius() float64Mass, height and radius.
func (c Character) Color() ColorColor.
func (c Character) SetColor(col Color)[server] Paints the character.
func (c Character) IsOnGround() boolfunc (c Character) IsCrouching() boolfunc (c Character) IsSprinting() boolfunc (c Character) IsSwimming() boolfunc (c Character) IsSeated() boolfunc (c Character) IsTumbling() boolfunc (c Character) IsDowned() boolMovement 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() UuidThe character type's uuid.
func (c Character) Unit() UnitThe AI unit controlling the character, if any.
func (c Character) SmoothViewDirection() Vec3The look direction, smoothed.
func (c Character) SurfaceNormal() Vec3The normal of the surface the character stands on.
func (c Character) IsDefaultColor() boolTrue if the character has its default color.
func (c Character) IsMoving() boolfunc (c Character) IsAiming() boolfunc (c Character) IsClimbing() boolfunc (c Character) IsLadderClimbing() boolfunc (c Character) IsDiving() boolfunc (c Character) IsFlying() boolfunc (c Character) IsHovering() boolMore movement state.
func (c Character) CanSwim() boolTrue 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() float64func (c Character) SprintSpeed() float64Base walking and sprinting speeds.
func (c Character) CurrentMovementSpeed() float64The current movement speed.
func (c Character) MovementSpeedFraction() float64The movement speed scale.
func (c Character) JumpSpeedFraction() float64func (c Character) SetJumpSpeedFraction(f float64)Reads / writes the jump height scale.
func (c Character) MovementNoiseRadius() float64How 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() Interactablefunc (c Character) SetLockingInteractable(i Interactable) boolfunc (c Character) LockingHarvestable() Harvestablefunc (c Character) SetLockingHarvestable(h Harvestable) boolThe 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() Vec3func (c Character) TumblingWorldRotation() Quatfunc (c Character) TumblingLinearVelocity() Vec3func (c Character) TumblingAngularVelocity() Vec3func (c Character) TumblingExtent() Vec3The 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) Vec3func (c Character) TpBoneRotation(bone string) QuatA bone's third person position / rotation.
func (c Character) ActiveAnimations() []ActiveAnimationThe animations playing now.
func (c Character) AnimationInfo(name string) AnimationInfoInformation 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() boolTrue 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() boolTrue once the character's graphics are loaded.
func (c Character) IsVisible() boolfunc (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() float64func (c Character) SetGlowMultiplier(v float64)Reads / writes the glow multiplier.
func (c Character) SetUpDirection(up Vec3)Sets which way is up for the character.
Player
Section titled "Player"type Player struct{ atl.Object }A connected player (Lua Player).
Methods
func (p Player) ID() intThe player's id.
func (p Player) Name() stringThe player's display name.
func (p Player) Character() CharacterThe player's current character.
func (p Player) Inventory() Containerfunc (p Player) Hotbar() ContainerThe player's inventory and hotbar.
func (p Player) IsMale() boolfunc (p Player) IsFemale() boolThe 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() boolTrue until the player has left.
func (p Player) CurrentToolUuid() UuidThe 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() ContainerThe 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() boolTrue for no item.
func (i *Item) FromLua(t atl.Value)Reads an item table.
Container
Section titled "Container"type Container struct{ atl.Object }An item container: inventory, chest, hotbar... (Lua Container).
Methods
func (c Container) Size() intNumber of slots.
func (c Container) Item(slot int) ItemThe item in a slot.
func (c Container) IsEmpty() boolfunc (c Container) IsFull() boolTrue if every / no slot is free.
func (c Container) CanCollect(item Uuid, quantity int) boolfunc (c Container) CanSpend(item Uuid, quantity int) boolTrue if quantity of item fit / can be taken.
func (c Container) CanCollectAll(items []Item) boolTrue if all of these items fit at once.
func (c Container) Count(item Uuid) intTotal quantity of an item.
func (c Container) MaxStackSize() intLargest stack per slot.
func (c Container) UniqueItems() []UuidEach item type present, once.
func (c Container) ItemUuids() []Uuidfunc (c Container) Quantities() []intEvery slot's uuid / quantity, in slot order.
func (c Container) FirstItem() ItemThe first non-empty slot's item.
func (c Container) Revision() intNetwork revision, bumped on every change.
func (c Container) HasChanged(tick int) bool[server] True if the container changed after tick.
func (c Container) AllowCollect() boolfunc (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) intfunc (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) intfunc (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) boolfunc (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() intThe world's id.
func (w World) IsIndoor() boolTrue for an indoor world.
func (w World) Destroy()[server] Destroys the world.
func (w World) CellBounds() CellBoundsReads the world's cell bounds.
func (w World) IsCellInBounds(x, y int) boolTrue 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)) LoadCellHandleKeeps 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.ValueThe 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) VoxelMaterialfunc (w World) DominantMaterialInCapsule(position Vec3, radius, height float64) VoxelMaterialThe most common voxel material in a sphere / capsule.
func (w World) VoxelMaterialAt(worldPosition Vec3) VoxelMaterialThe voxel material at a point.
func (w World) WeightedVoxelDensityAt(point Vec3) WeightedDensityReads the interpolated voxel density at a point.
func (w World) IsVoxelTerrainPointClear(referencePosition, testPosition Vec3) boolTrue 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).
CellBounds
Section titled "CellBounds"type CellBounds struct { MinX, MaxX, MinY, MaxY int}The range of cell coordinates the world covers.
VoxelMaterial
Section titled "VoxelMaterial"type VoxelMaterial struct { Material int Density int Position Vec3}A voxel material and density, and (for dominant material queries) a position.
WeightedDensity
Section titled "WeightedDensity"type WeightedDensity struct { Density float64 Gradient Vec3}Voxel density and its gradient at a point.
Harvestable
Section titled "Harvestable"type Harvestable struct{ atl.Object }A tree, rock, plant or kinematic object (Lua Harvestable).
Methods
func (h Harvestable) ID() intThe harvestable's id.
func (h Harvestable) Uuid() Uuidfunc (h Harvestable) Name() stringfunc (h Harvestable) Type() stringIts item uuid, name and type.
func (h Harvestable) Position() Vec3func (h Harvestable) Rotation() Quatfunc (h Harvestable) Scale() Vec3Position, rotation and scale.
func (h Harvestable) Color() ColorColor.
func (h Harvestable) SetColor(c Color)Paints the harvestable.
func (h Harvestable) Destroy()[server] Destroys the harvestable.
func (h Harvestable) World() WorldThe 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() Vec3func (h Harvestable) AngularVelocity() Vec3Velocity and angular velocity.
func (h Harvestable) Mass() float64Mass in kilograms.
func (h Harvestable) Material() stringfunc (h Harvestable) MaterialID() intThe physics material name and id.
func (h Harvestable) Aabb() Aabbfunc (h Harvestable) LocalAabb() AabbWorld-space / local-space bounds.
func (h Harvestable) TransformPoint(worldPoint Vec3) Vec3func (h Harvestable) TransformLocalPoint(localPoint Vec3) Vec3func (h Harvestable) TransformDirection(worldDir Vec3) Vec3World point to local / local point to world / world direction to local.
func (h Harvestable) IsKinematic() boolTrue for a kinematic (scripted, movable) harvestable.
func (h Harvestable) IsCellKinematic() boolTrue for a kinematic placed by a cell (vs. created from a script).
func (h Harvestable) InitialHash() float64Identifies a kinematic across reloads (harvestables.ByInitialHash).
func (h Harvestable) Data() atl.ValueThe 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() boolfunc (h Harvestable) SeatCharacter() Characterfunc (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() intfunc (h Harvestable) SetUvFrameIndex(index int)[client] Reads / writes the UV frame.
func (h Harvestable) PoseWeight(index int) float64func (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.
Network
Section titled "Network"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.
Effect
Section titled "Effect"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() boolTrue while playing.
func (e Effect) IsDone() boolTrue 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() intThe 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() boolfunc (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.
CameraData
Section titled "CameraData"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() intThe tool's id.
func (t Tool) Uuid() UuidThe tool's item uuid.
func (t Tool) Owner() PlayerThe player holding it.
func (t Tool) IsLocal() boolTrue on the owner's client.
func (t Tool) IsEquipped() boolTrue while equipped.
func (t Tool) IsInFirstPersonView() boolfunc (t Tool) IsCrouching() boolfunc (t Tool) IsSprinting() boolfunc (t Tool) IsOnGround() boolThe owner's view and movement state.
func (t Tool) Position() Vec3func (t Tool) Direction() Vec3Position and aim direction of the tool.
func (t Tool) SmoothDirection() Vec3Aim direction, smoothed.
func (t Tool) MovementVelocity() Vec3The owner's movement velocity.
func (t Tool) MovementSpeedFraction() float64The 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) Vec3func (t Tool) TpBonePosition(bone string) Vec3[client] A bone's first / third person position.
func (t Tool) FpBoneDirection(bone string, worldSpace bool) Vec3func (t Tool) FpBoneRotation(bone string, worldSpace bool) Quatfunc (t Tool) TpBoneDirection(bone string) Vec3func (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).
CameraWeights
Section titled "CameraWeights"type CameraWeights struct { ThirdPerson, FirstPerson float64}Weights of the third / first person camera settings.
LoadCellHandle
Section titled "LoadCellHandle"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() intThe lift's id.
func (l Lift) Level() intIts height level.
func (l Lift) WorldPosition() Vec3Its position.
func (l Lift) HasBodies() boolTrue if it carries bodies.
func (l Lift) Destroy()[server] Removes the lift.
Portal
Section titled "Portal"type Portal struct{ atl.Object }A two-opening portal between (or within) worlds. All [server].
Methods
func (p Portal) ID() intThe portal's id.
func (p Portal) HasOpeningA() boolfunc (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() Vec3func (p Portal) PositionB() Vec3func (p Portal) RotationA() Quatfunc (p Portal) RotationB() Quatfunc (p Portal) WorldA() Worldfunc (p Portal) WorldB() World[server] Positions, rotations and worlds of the two openings.
func (p Portal) ContentsA() []Targetfunc (p Portal) ContentsB() []Target[server] Characters and bodies in each opening.
func (p Portal) TransferAToB(filter *int) boolfunc (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.
Storage
Section titled "Storage"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.
Target
Section titled "Target"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() stringLua'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() Vec3func (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.Valuefunc (u Unit) SetPublicData(t atl.Value)[server] Data other scripts can read, and setting it.
func (u Unit) Container(index int) ContainerA 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.
AiState
Section titled "AiState"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() Vec3func (a AiState) MovementDirection() Vec3func (a AiState) MovementType() stringfunc (a AiState) WantsJump() boolfunc (a AiState) WantsCrouch() bool[server] What the state wants the unit to do; apply it with the Unit setters.
AiStateDone
Section titled "AiStateDone"type AiStateDone struct { Done bool Reason string}Whether the behaviour has finished, and why.
PathNode
Section titled "PathNode"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.
ScriptableObject
Section titled "ScriptableObject"type ScriptableObject struct{ atl.Object }A scriptable object: a script with no body in the world (Lua ScriptableObject).
Methods
func (s ScriptableObject) ID() intThe object's id.
func (s ScriptableObject) World() WorldThe world it's in.
func (s ScriptableObject) Data() atl.ValueThe 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.
ClientScriptableObject
Section titled "ClientScriptableObject"type ClientScriptableObject struct{ atl.Object }A scriptable object that only exists on one client (clientscriptableobjects.Create). All [client].
Methods
func (s ClientScriptableObject) ID() intThe object's id.
func (s ClientScriptableObject) World() WorldThe world it's in.
func (s ClientScriptableObject) Data() atl.ValueThe params it was created with.
func (s ClientScriptableObject) ClientPublicData() atl.Valuefunc (s ClientScriptableObject) SetClientPublicData(t atl.Value)Data other client scripts can read, and setting it.
func (s ClientScriptableObject) Destroy()Destroys the object.
ProjectileHit
Section titled "ProjectileHit"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) ProjectileHitBuilds the struct from callback arguments starting at index i.
MeleeHit
Section titled "MeleeHit"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) MeleeHitBuilds the struct from callback arguments starting at index i.
CollisionHit
Section titled "CollisionHit"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) CollisionHitBuilds the struct from callback arguments starting at index i.
WorldProjectileHit
Section titled "WorldProjectileHit"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) WorldProjectileHitBuilds the struct from callback arguments starting at index i (server calls carry CustomData).
WorldMeleeHit
Section titled "WorldMeleeHit"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) WorldMeleeHitBuilds the struct from callback arguments starting at index i.
WorldCollision
Section titled "WorldCollision"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) WorldCollisionBuilds the struct from callback arguments starting at index i.
AreaTrigger
Section titled "AreaTrigger"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) AreaTriggerWraps an existing Lua trigger.
func TrackTrigger(v atl.Value) AreaTriggerWraps a Lua trigger so it's destroyed with the current script.
Methods
func (t *AreaTrigger) ID() intThe trigger's id.
func (t *AreaTrigger) WorldPosition() Vec3func (t *AreaTrigger) WorldRotation() Quatfunc (t *AreaTrigger) SetWorldPosition(p Vec3)func (t *AreaTrigger) SetWorldRotation(q Quat)Position and rotation in the world.
func (t *AreaTrigger) Size() Vec3func (t *AreaTrigger) SetSize(s Vec3)Size of the volume (box extents, or radius and length for spheres and cylinders).
func (t *AreaTrigger) WorldBounds() AabbThe world-space bounding box.
func (t *AreaTrigger) World() WorldThe world the trigger is in.
func (t *AreaTrigger) UserData() atl.ValueThe user data passed at creation.
func (t *AreaTrigger) HostInteractable() InteractableThe interactable the trigger is attached to, if any.
func (t *AreaTrigger) Contents() []TargetEverything currently inside.
func (t *AreaTrigger) Shapes() []Shapefunc (t *AreaTrigger) Characters() []Characterfunc (t *AreaTrigger) Harvestables() []HarvestableOnly 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)) *AreaTriggerfunc (t *AreaTrigger) OnExit(fn func(objects []Target)) *AreaTriggerfunc (t *AreaTrigger) OnStay(fn func(objects []Target)) *AreaTriggerCalled with the objects that entered, left, or stayed inside this tick.
func (t *AreaTrigger) OnProjectile(fn func(hit ProjectileHit)) *AreaTriggerCalled when a projectile hits the trigger.
func (t *AreaTrigger) OnMelee(fn func(hit MeleeHit)) *AreaTriggerCalled when a melee attack hits the trigger.
func (t *AreaTrigger) OnInteract(fn func(character Character, pressed bool)) *AreaTriggerCalled when a character interacts with the trigger.
func (t *AreaTrigger) CanInteract(fn func(character Character) bool) *AreaTriggerDecides whether a character may interact with the trigger.
func (t *AreaTrigger) OnDestroy(fn func()) *AreaTriggerCalled when the trigger is destroyed.
func (t *AreaTrigger) OnHostDestroy(fn func()) *AreaTriggerfunc (t *AreaTrigger) OnHostUnload(fn func()) *AreaTriggerCalled when the object the trigger is attached to is destroyed / unloaded (host only).
func (t *AreaTrigger) CanErase(fn func() bool) *AreaTriggerfunc (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() boolTrue when touching voxel terrain.
func (t *AreaTrigger) SetVoxelDestructible(destructible bool)Whether the trigger can destroy voxel terrain.
Garage
Section titled "Garage"type Garage struct{ atl.Object }A blueprint import area, like the survival garage.
Methods
func (g Garage) Position() Vec3The garage's position.
func (g Garage) Bounds() AabbThe garage's bounds.
func (g Garage) HasActiveTracking() boolTrue while a blueprint is tracked.
func (g Garage) TrackingRevision() intChanges 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() GarageBlueprintReads the tracked blueprint.
func (g Garage) BlueprintBounds() AabbThe tracked blueprint's bounds.
func (g Garage) CreationFits() *boolWhether the tracked creation fits; nil when nothing is tracked.
func (g Garage) Placement() *Vec3Where the creation would be placed.
func (g Garage) ImportBlueprint()Imports the tracked blueprint.
GarageBlueprint
Section titled "GarageBlueprint"type GarageBlueprint struct { Name string Json atl.Value}The tracked blueprint's name and contents.