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 resultThe game loop calls ScriptEngine::tick() each frame:
- If a pending command was resolved by Rust,
run_jobs()drains the JS microtask queue so the async function continues to its nextawait. - If the script issues a new command, it’s returned to the caller for dispatch.
- 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;