Files
feuerwerk/src/core/graph/nodes/data/ToNumber.ts
T
rootandClaude Opus 5 4f78c7518c Give the graph a loop, and build Tetris with it
A Tetris example project needs to draw 200 board cells and scan rows
for a full line. Neither is expressible without iteration, so the node
system gets a Repeat node plus the missing text side: Substring, Find
text and To number. The interpreter drops its data cache once per
round -- otherwise every round would recompute with the first round's
values.

Object by name takes its name as an input now, not just as a setting;
addressing "c" + index is impossible otherwise. An unconnected input
reads the stored setting, so saved projects are untouched.

The board itself is a 200-character text, "." for empty. That makes
both operations of Tetris a single expression instead of a loop, and
each frame attempts exactly one move -- rotate beats sideways beats
fall -- so the fit check exists once in the whole graph.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-09 19:10:41 +02:00

15 lines
486 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import type { NodeDef } from '../../NodeRegistry';
import { asNumber } from '../../values';
import { any, num } from '../shared';
export const ToNumber: NodeDef = {
type: 'ToNumber',
label: 'To number',
category: 'data',
description: 'Reads a text as a number. Anything that is not one – an empty text, a word – reads as 0.',
inputs: [any('value')],
outputs: [num('result')],
params: [],
run: (_ctx, inputs) => ({ outputs: { result: asNumber(inputs.value) } }),
};