Let a variable hold an object across behavior runs
game-maker / gate (push) Successful in 3m15s
game-maker / suite (push) Failing after 9m2s

A spawned object was only reachable in the run that spawned it. The
Spawn output could not go into a variable because "object" was a
port-only kind, so the next run had no way back to the instance.

- "Object" is now a variable kind. The reference lives for the run
  only. The file stores the declaration and an empty value.
- The live reference sits in slots beside the variable bag
  (graph/objectSlots.ts), not in it. The bag is the behavior's props,
  and syncToModel would have written an object into the scene.
- A destroyed object, or one from a restarted or left scene, reads as
  nothing. A dead reference is dropped from its slot.
- Keep (#229) hands the slots of kept variables on to the next call
  of a sub-behavior.
- Properties of kind Behavior reads and writes another behavior's
  object variable through the same slots.
- The inspector shows "(null)" for it and offers no input.
- A persistent Variables asset with an object variable shows a
  warning under "Persistent". Saved values never keep the object,
  every run starts it at (null).

Objects inside lists and struct fields are left out on purpose.
Emptiness is checked with Equals against an empty b. A node "Is
valid" does not exist yet.

The test helper graphEditor().variables() now also reads the kinds
of a Variables asset a node points to.

Tests:
- ./check.sh: 169 files, 2463 tests, CHECK EXIT 0
- e2e 6 + 23: ALL PASSED, 146 checks (new 23k, 2 checks)
- e2e 32: ALL PASSED, 18 checks (new 32f-ii)
- 10 unit tests in tests/core/object-variable.test.ts, one of them
  runs a persistent asset over two runs
- 5 counter-probes (value in bag, isAlive always true, no Keep
  hand-over, Properties without slots, object in saved values) each
  fail their test
- e2e check total 1406, computed only

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Opus 5.5 committed 2026-09-26 20:15:16 +02:00
1 parent 923baf2557
commit 98211a8d54
16 files changed
+375 -11

No files matched your search

+16
View File
@@ -176,6 +176,22 @@ export async function scope(t) {
);
await shot('04-persistent');
// 32f-ii. An object variable in a persistent asset is allowed, but is never saved: the inspector
// says so once there is one, and the note goes again with it.
const objectNote = 'Object variables are not kept,';
const noteBefore = await has(objectNote);
await clickLast('+ Variable');
await clickLast('Object');
const noteWith = await has(objectNote);
await shot('04b-persistent-object');
await t.undo();
const noteAfter = await has(objectNote);
check(
'a persistent asset with an Object variable notes that the object is not kept',
!noteBefore && noteWith && !noteAfter && (await asset('sc-vars')).variables.length === 1,
JSON.stringify({ noteBefore, noteWith, noteAfter }),
);
const scoreOfRun = async () => {
await t.play();
await sleep(600);