Replace the five variable nodes with one Variables node
A single node now lists any number of variables. Every entry is an output that reads the current value whenever it is pulled; an entry switched to Set is also an input and is written when the flow arrives. Exec pins only exist while at least one entry writes, and all inputs are read before any write, so one node can swap two variables. Get/Set variable, Get/Set variables and Variable are gone. Old project files are converted on load: each old node becomes a Variables node with the same variables, edges and typed values. A written port without a typed value now shows the zero of its kind on the node body, matching what the inspector shows and what the run writes. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
854ae2e756
commit
7c63c884ef
40 files changed
+895
-590
No files matched your search
@@ -106,29 +106,18 @@ const CASES: Record<string, Case[]> = {
|
||||
|
||||
// variables
|
||||
|
||||
GetVariable: [
|
||||
{ name: 'reads a variable', params: { variable: 'speed' }, outputs: { value: 100 } },
|
||||
{ name: 'an unknown variable reads as null', params: { variable: 'nope' }, outputs: { value: null } },
|
||||
{ name: 'no variable chosen reads as null', outputs: { value: null } },
|
||||
],
|
||||
GetVariables: [
|
||||
// Reading needs the interpreter, which asks `read` at the moment: see variable-node.test.ts.
|
||||
Variables: [
|
||||
{
|
||||
name: 'reads one output per variable it names',
|
||||
name: 'writes the variables switched to Set, each keeping its declared type',
|
||||
ports: [
|
||||
{ key: 'speed', kind: 'number' },
|
||||
{ key: 'nope', kind: 'number' },
|
||||
{ key: 'speed', kind: 'number', write: true },
|
||||
{ key: 'lives', kind: 'number' },
|
||||
],
|
||||
outputs: { speed: 100, nope: null },
|
||||
},
|
||||
{ name: 'without a variable it reads nothing', outputs: {} },
|
||||
],
|
||||
SetVariables: [
|
||||
{
|
||||
name: 'writes every variable it names, each keeping its declared type',
|
||||
ports: [{ key: 'speed', kind: 'number' }],
|
||||
inputs: { speed: '250' },
|
||||
inputs: { speed: '250', lives: 9 },
|
||||
context: { variables: { speed: 100, lives: 3 } },
|
||||
next: 'exec',
|
||||
after: (ctx) => expect(ctx.variables.speed).toBe(250),
|
||||
after: (ctx) => expect(ctx.variables).toEqual({ speed: 250, lives: 3 }),
|
||||
},
|
||||
{
|
||||
name: 'without a variable it writes nothing',
|
||||
@@ -136,37 +125,6 @@ const CASES: Record<string, Case[]> = {
|
||||
after: (ctx) => expect(ctx.variables).toEqual({ speed: 100 }),
|
||||
},
|
||||
],
|
||||
SetVariable: [
|
||||
{
|
||||
name: 'writes a variable, keeping the declared type',
|
||||
inputs: { value: '250' },
|
||||
params: { variable: 'speed' },
|
||||
next: 'exec',
|
||||
after: (ctx) => expect(ctx.variables.speed).toBe(250),
|
||||
},
|
||||
{
|
||||
name: 'no variable chosen writes nothing',
|
||||
inputs: { value: 5 },
|
||||
next: 'exec',
|
||||
after: (ctx) => expect(ctx.variables).toEqual({ speed: 100 }),
|
||||
},
|
||||
],
|
||||
// Reading without a flow needs the interpreter: see variable-node.test.ts.
|
||||
Variable: [
|
||||
{
|
||||
name: 'writes its variable when the flow arrives, keeping the declared type',
|
||||
inputs: { value: '250' },
|
||||
params: { variable: 'speed' },
|
||||
next: 'exec',
|
||||
after: (ctx) => expect(ctx.variables.speed).toBe(250),
|
||||
},
|
||||
{
|
||||
name: 'no variable chosen writes nothing',
|
||||
inputs: { value: 5 },
|
||||
next: 'exec',
|
||||
after: (ctx) => expect(ctx.variables).toEqual({ speed: 100 }),
|
||||
},
|
||||
],
|
||||
|
||||
// references and properties
|
||||
|
||||
|
||||
Reference in new issue
Block a user