Aego Русский

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

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")
        }
    }
}