Skip to main content

Crate dotzuki_engine_script

Crate dotzuki_engine_script 

Source
Expand description

dotzuki-engine-script — an async JavaScript scripting engine (Boa-based) for games.

Provides an async/await-based scripting system using Boa (a pure-Rust JS engine) that replaces the hardcoded ScriptAction queue. Map scripts are written in JavaScript and can await game operations like showText(), moveNpc(), etc.

§Architecture

JS Script (async fn)
    │
    ├─ await game.showText("...")  ──► ScriptCommand::ShowText
    │       ↑ Rust resolves promise when text dismissed
    │
    ├─ game.getFlag("GOT_STARTER") ──► synchronous bool return
    │
    └─ await game.startBattle("RIVAL") ──► ScriptCommand::StartBattle
            ↑ Rust resolves promise with battle result

The game loop calls ScriptEngine::tick() each frame:

  1. If a pending command was resolved by Rust, run_jobs() drains the JS microtask queue so the async function continues to its next await.
  2. If the script issues a new command, it’s returned to the caller for dispatch.
  3. If no script is active, returns None.

Re-exports§

pub use api_registrar::ScriptApiRegistrar;
pub use command::CommandResult;
pub use command::ScriptCommand;
pub use config::MapScriptConfig;
pub use cutscene::CutsceneManager;
pub use engine::BridgeView;
pub use engine::ScriptEngine;
pub use engine::ScriptEngineError;
pub use loader::ScriptLoader;
pub use loader::ScriptLoaderError;

Modules§

api_registrar
ScriptApiRegistrar trait — enables game-agnostic JS API registration.
command
config
cutscene
Cutscene system built on top of the Boa JS engine’s async/await.
engine
game_api
loader