Skip to content

Two wrong builds: order() with orders.Move, and functions that keep a state - #42

Merged
jeany55 merged 2 commits into
trigscript-4from
wrong-builds
Oct 20, 2026
Merged

jeany55 merged 2 commits into
trigscript-4from
wrong-builds

Conversation

@jeany55

@jeany55 jeany55 commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Two scripts that built maps doing the wrong thing, in both builds (eudplib's and our own).

order() with orders.Move. It made an Order action of modifier 6, the number orders.dat has for Move, where the action knows only 0, 1 and 2 (move, patrol, attack). Any other orders.* passed as a number too, and orders.Die and orders.Stop were taken for move and patrol. Now orders.Move, orders.Patrol and orders.AttackMove give the action's own numbers, and any other order is a type error. A raw number is a second signature: in one union with it, TypeScript took Order<0> for a number.

A function that keeps a state was worked out once when the script was built. A function changing a variable declared outside it (a closure's, or a let of the file's), or a field of this outside a constructor, was worked out where its call was written. A loop printing next() of const next = counter() showed 1, 1, 1. A call of such a function is now the program's (hoist.ts, keepsState):

  • a closure made in the program runs in the game;
  • one made when the script was built, or a method of an instance made then, is refused;
  • a function writing the script's own let or record is refused, as that write is when written in the program.

A cache filled by a method stays a build-time call. A diagnostic said again for each call of the same function is now said once.

Ledger: game/order.ts describes the three orders the action takes. language/closure-keeps-a-count.ts is new. Both stay refused by a map of our own (steps 5 and 9), and no other row changed.

Tests: tests/events.test.ts, tests/script-functions.test.ts, tests/script-structured.test.ts. Suite 1,244 passing.

🤖 Generated with Claude Code

https://claude.ai/code/session_01T1CM9pLuTuAn3mgTEkjgVg

jeany55 and others added 2 commits October 19, 2026 23:58
…Move as move, patrol and attack

orders.Move made an Order action of modifier 6, orders.dat's number, where the action knows 0, 1 and 2; any other
of orders.* passed as a number too, orders.Die and orders.Stop taken for move and patrol. The three the action
gives are now its own numbers, every other a type error (a raw number is a second signature: in one union with
it, TypeScript took Order<0> for a number).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T1CM9pLuTuAn3mgTEkjgVg
…hen the script is built

A function changing a variable declared outside it (a closure's, a let of the file's) or a field of this outside a
constructor was worked out where its call was written: a loop printing next() of `const next = counter()` showed
1, 1, 1. A call of it is now the program's (hoist.ts keepsState): a closure made in the program runs in the game;
one made when the script was built, or a method of an instance made then, is refused; a function writing the
script's own let or record is refused as the write written in the program is. A cache filled by a method stays a
build-time call. Diagnostics said again for each call of the same function are said once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T1CM9pLuTuAn3mgTEkjgVg
@jeany55
jeany55 merged commit 9a0fa08 into trigscript-4 Oct 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant