Wait and both kinds of until loops; blocks run directly

Script runs are resumable threads saved with the game; Rhai is gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Richard ZinkandClaude Opus 5.5 committed 2026-11-05 18:57:36 +01:00
1 parent 95cf3ce81c
commit d17668f3b2
13 files changed
+466 -686

No files matched your search

+3 -4
View File
@@ -69,11 +69,10 @@ But before committing a completed change, the full local checks should pass unle
## Campaign scripting conventions
- Mission scripts are **blocks** (`src/blocks.rs`), edited in the in-game block editor (`src/editor/blocks_ui.rs`); players never see code.
- Blocks are translated into Rhai internally and run by `src/mscript.rs` inside the fixed simulation step (deterministic, co-op safe).
- The Rust Rhai dependency must keep `no_time` enabled in `Cargo.toml` so the WASM output stays loadable by the macroquad JS bundle.
- Rhai reserves `spawn`; the internal API uses `spawn_unit`.
- The blocks are run directly by the interpreter in `src/mscript.rs` inside the fixed simulation step (deterministic, co-op safe); there is no scripting language underneath (Rhai was removed when "wait" came).
- Script runs are threads (resumable after "wait", saved with the game); loops have a step budget per check so nothing can hang.
- Per mission: special scripts (start, victory check, defeat check, clock) and triggers (`TriggerKind` in `src/campaign_doc.rs`).
- New block kinds need: the `Block`/`Val` variant, `template`/`kind_name`, palette entry, checking, Rhai translation, the API function in `mscript.rs`, the editor fields in `blocks_ui.rs`, `blk.*` texts in every language file, and a test.
- New block kinds need: the `Block`/`Val` variant, `template`/`kind_name`, palette entry, checking (`blocks::check`, `vars_set`), execution in `mscript.rs` (`exec`/`run_thread`/`eval`), nesting in `list_at` (mscript) and `list_mut` (blocks_ui) if it has a body, the editor fields in `blocks_ui.rs`, `blk.*` texts in every language file, and a test.
- Side numbers: -1 any, 0 player, 1 heroes, 2 Mossgrim, 3 Lady Nightwell, 4 rival 3.
- Unknown creature names, zones, triggers and unset variables are reported by `blocks::check`.
- Reference: `docs/CAMPAIGN_EDITOR.md` and `docs/MISSION_SCRIPTING.md`.