Aego Script
Aego Script is the gameplay language of Aego. It is statically typed and reads like Go. Scripts attach to nodes, show fields in the Inspector, read and write components, call engine and native functions and talk to each other through signals.
These pages describe the language. Overview walks through one script, an enemy that patrols, and the other pages explain each part. The functions of the engine are listed in the Script API reference.
package demo
import "aego/log"
script Hello {
@export var Greeting string = "hello from Aego Script"
var frames int
func Ready() {
log.Info(Greeting + " on node " + node.Name())
}
func Update(dt float) {
frames++
if frames == 60 {
log.Info("one second of frames: " + string(frames))
}
}
}
- Overview This page reads one complete script: an enemy that walks back and forth, waits at each end and tells other scripts when it turns.
- Files and packages Source files use the
.aesextension and live underscripts/in the project. - Lexical structure Identifiers are ASCII only:
[A-Za-z_][A-Za-z0-9_]*. - Grammar Precedence, high to low: unary
-!;* / %;+ -;== != < <= > >=;&&;||. - Types Rules:
- Declarations and statements
var x T,var x T = e— explicit type;x := e— inferred frome(untyped constants default toint/float);nilcannot initialise:=. - Scripts and lifecycle A
scriptis a stateful type that attaches to a node. - Attributes Exportable field types:
bool int float string Vec2 Vec3 Color Quat Rect, enums,NodeRef,AssetRef<T>,ComponentRef<T>. - Nodes, components and references Transforms are read and written by value:
t := node.Transform2D(); t.Position.X += 1; node.SetTransform2D(t). - Standard library The standard library is the set of
aego/…packages every script can import. - Native bindings Project Go code in
native/exposes functions, constants and component members through the SDK. - Runtime behaviour A fault stops only the instance that caused it (its methods, coroutines and handlers are no longer called); the rest of the scene keeps running.
- Limits 255 registers per function · 32 767 instructions per function · 32 value slots per slice element · 255 script-visible fields per component (checked when the component is registered) · call depth 256 · 1 000 000 instructions per call into a script (configurable).
- Diagnostics Compiler diagnostics have a code, file, line and column, and often a note:
- CLI All of them use the same workspace as the editor and hot reload.
- Coroutines A coroutine is a script method that can pause and continue on a later frame.
- Signals
signal Name(params)inside a script. - ScriptRef
node.GetScript<T>()returns theScriptRef<T>of scriptTon that node, ornilwhen the node has none. - Hot reload Saving a script while the game runs (
aego run, Play in the editor) swaps the code without restarting. - Editor The editor's code editor, navigation, completion, hover, library stubs, Problems panel and Profiler sections for scripts are described in Editor.
- Data assets A data type registered by a native module is available to scripts by its short name.
- Keywords and builtins Every keyword, builtin type and builtin function of Aego Script.