A state can transition to itself: make transition and a second click on the same state connects a self transition, taking it fires On state exited and then On state entered every time, for local and global machines, while Set state into the current state stays silent as before; only states may connect to themselves, every other node is still refused, one self transition per state; the loop is drawn over the middle of the top edge with its arrow pointing down and its name at the apex, the preview already shows it while armed, and the inspector lists it once under Transitions out; new test hook transitionLabelAt, e2e 26e5 (#163)
game-maker / gate (push) Successful in 1m56s
game-maker / suite (push) Successful in 6m45s

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Opus 5 committed 2026-09-19 16:10:02 +02:00
1 parent cc285af10a
commit 010b6a7f6c
12 files changed
+355 -33

No files matched your search

+4 -3
View File
@@ -93,13 +93,14 @@ export function currentState(ctx: NodeContext, machineId: string): string {
/**
* The one way a machine moves: writes the new state and reports the move. Into the state it is
* already in is no move – nothing is written, and nothing fires, which is what keeps a `Set state`
* run every frame from firing `entered` every frame.
* run every frame from firing `entered` every frame. `reenter` is the exception a transition drawn
* back into its own state asks for: the state is left and entered again, both events included.
*/
export function setState(ctx: NodeContext, machineId: string, next: string): void {
export function setState(ctx: NodeContext, machineId: string, next: string, reenter = false): void {
if (!machineId) return;
const bag = stateBag(ctx, machineId);
const previous = bag[machineId] ?? '';
if (previous === next) return;
if (previous === next && !reenter) return;
bag[machineId] = next;
ctx.stateChanged(machineId, previous, next);
}