Skip to content
AEOWUN
Docs Menu

Entity scripts

Keep per-object state and respond to lifecycle calls.

Declare an Entity script

entity Counter {
    count: number = 0
    fn update(dt) {
        count += 1
    }
}

Bind the script to the object that owns this behavior. Declaring lifecycle functions alone does not attach the script to an object.

Lifecycle

Common functions are on_spawn(), on_ready(), update(dt), and on_destroy(). Use only the ones you need. Fields keep their values between lifecycle calls. Separate instances keep separate field values.

Choose the right model

Use top-level code for game-wide startup. Use Actor-attached Modules for Actor behavior. An entity declaration and a live Entity handle are different things. See Live Entities for runtime object controls.

[BETA] marks features newer than the current public release. Current release: 0.8.0.