docs/style.md, docs/glossary.md, style checks DOC010–DOC023 and docs report; the site in a light theme; the Editor, Aego Script, Gameplay, Physics, Scenes, Rendering, Tools and Reference sections rewritten.
2.2 KiB
2.2 KiB
id, icon, parent, order, title
| id | icon | parent | order | title |
|---|---|---|---|---|
| language/standard-library | code.block | language | 10 | Standard library |
Standard library
The standard library is the set of aego/… packages every script can import. Each package has its own page in the Script API reference with every function; this page says what each one is for.
| Package | For |
|---|---|
aego/math |
numbers, vectors and rotations |
aego/log |
messages in the Console |
aego/rand |
random numbers from the game's seed |
aego/time |
frame time, fixed step and elapsed time |
aego/input |
actions, contexts and raw keys; see Input |
aego/settings |
player and project settings; see Settings |
aego/scene |
finding, creating and destroying nodes |
aego/testing |
assertions in script tests |
Engine modules add their own packages, such as aego/physics and aego/audio. They are listed in the same reference.
Rules worth knowing
- There is no overloading. Vec3 variants carry a
3suffix (Dot3), int variants anIntsuffix (ClampInt). - Build log messages with
+andstring(x). aego/randdraws from the world's seeded generator, so a replay with the same seed gives the same numbers.- Nodes made with
scene.Instantiateappear at the end of the phase. Their scripts receiveReadybefore the nextUpdate. aego/testingis available only underaego test. A failed assertion stops the test and reports the file and line.
Run it:
package demo
import (
"aego/log"
"aego/math"
"aego/rand"
"aego/scene"
"aego/time"
)
script Wander {
@export var Speed float = 2
var dir Vec2
func Ready() {
dir = math.Normalize(Vec2{rand.Range(-1, 1), rand.Range(-1, 1)})
log.Info("found myself: " + string(scene.Find("Wander") == node))
}
func Update(dt float) {
node.SetPosition(node.Position() + dir * Speed * dt)
if time.Frame() % 40 == 0 {
p := node.Position()
log.Info("t=" + string(time.Elapsed()) + " s, " + string(math.Length(p)) + " units from the start")
}
}
}