Skip to content

Search

Indietro
· 2 min di lettura

Rune scripting

Rune scripts on nodes, components as fields, a reference read out of a running engine, and completion, hover and linting in the editor.

Rune is the scripting language. A script is one object per node, and every component on the node is a field it calls.

  • update(this, dt) runs every frame, and fixed_update on the fixed step, before physics.
  • exports() returns the defaults. A scene overrides only what it changes, and the inspector lists them per node.
  • Each component is a field on the node with every function that drives it, plus get(), set(), has() and remove().
  • The modules, components and assets references are read out of a running engine, and CI fails when they drift.
pub fn exports() {
    #{ speed: 2.0 }
}

pub fn fixed_update(this, dt) {
    this.node.body2d.apply_impulse(this.speed * dt, 0.0);
}

Tooling

The completion popup under the caret, on a module path

  • After physics2d:: completion lists that module, and after node.body2d. what acts on that component.
  • ⌘B goes to a definition, ⌘⇧R renames across files, and ⌥⇧F formats.
  • The Problems dock checks on save for a missing script, prefab or asset, and for a shader that will not link.
  • A VS Code extension spawns balaur lsp, which runs the same checks.

The Script persona with platform.rn open on the bad call, and the Problems dock under it naming the line and the method

  • balaur check resolves every component method a script calls against the scene it runs on, and a misspelled one names its file and line.
  • Findings are warnings, and --strict makes them errors for CI.

Docs