From 9087225e9fc72dc4a7c76f6f23e25f972323b883 Mon Sep 17 00:00:00 2001 From: meleki Date: Wed, 23 Sep 2026 06:07:08 +0200 Subject: [PATCH] Scope scene for Variables assets and state machines (#164) Behaviors: Scope on the Variables asset. State machines: third step and the announcement after a swap. Development: check sum 1307. --- Behaviors.md | 6 ++++++ Development.md | 2 +- State-machines.md | 6 +++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Behaviors.md b/Behaviors.md index fbda696..e6f9db2 100644 --- a/Behaviors.md +++ b/Behaviors.md @@ -224,6 +224,12 @@ shown on the node and editable in the inspector. next run starts from. Two Variables assets may declare the same name without meeting: the asset is the key, not the name. A coin counter is one such asset with `coins` in it; picking a coin up is one node, `coins` fed through `Add` back into itself. +- **Scope**: a Variables asset is shared either way, and the dropdown says for how long. **Global** + (the default) is the whole run: the values travel through every `Load scene`, which is what lets + a score survive the next level. **Scene** is one set per scene, built again from the declarations + whenever a scene is loaded — for what a level counts and the level takes with it, like the + enemies left in it or a switch that was flipped. A scene asset cannot be persistent; there is + nothing to keep between runs when every scene throws the values away, so that switch is not shown. - **Saved values (savegame)**: tick **Persistent** in a Variables asset's inspector and its values outlive the run — a highscore, the levels unlocked, the player's settings. The next Play starts where the last one ended instead of at the declared values. Nothing new is needed in the graph: diff --git a/Development.md b/Development.md index 2613a11..7bd9044 100644 --- a/Development.md +++ b/Development.md @@ -13,7 +13,7 @@ npm run check # typecheck + lint + format:check + tests, the gate CI runs npm run build # writes dist/ and regenerates index.html ./build.sh # the same under `set -o pipefail`, for callers that pipe the output php tools/make-user.php # an account; every tool signs in (see Accounts) -node tools/seed-e2e.mjs && node tools/e2e.mjs # 1304 editor checks, screenshots in /tmp/gm-e2e-*.png +node tools/seed-e2e.mjs && node tools/e2e.mjs # 1307 editor checks, screenshots in /tmp/gm-e2e-*.png GM_STEPS=20 node tools/e2e.mjs # or 1-12, or 6,20 — a subset while working on one step ./e2e.sh start [GM_STEPS] # the same run detached, see below ./e2e.sh status # live progress, or the last run's result diff --git a/State-machines.md b/State-machines.md index dbf1ed4..668ee52 100644 --- a/State-machines.md +++ b/State-machines.md @@ -13,7 +13,11 @@ A machine's **Scope** is a dropdown in its own inspector, since the machine is t current state hangs off its id. **Local** (the default) gives every behavior instance a current state of its own — two doors open independently. **Global** keeps one current state for the whole run, so every behavior using the machine sees the same one, and a second behavior can branch on a -state it never set itself. Scope also decides who hears a move: see *Start state and events* below. +state it never set itself. **Scene** shares one the same way, but only for as long as the scene +lasts: every `Load scene` puts the machine back into its start state, and that entry is announced +again, so an `On state entered` in the new scene hears it. A global machine stays quiet there, +because it never left the state it was in. Scope also decides who hears a move: see *Start state +and events* below. ## Transitions