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
@@ -45,11 +45,11 @@ function callerOf(fixture: ProjectFixture, callee: BehaviorAsset, input: number)
|
||||
const edit = graphEditor(fixture, asset);
|
||||
const start = edit.addNode('OnStart');
|
||||
const call = edit.addNode(RUN_BEHAVIOR, { [BEHAVIOR_PARAM]: callee.id, in1: input });
|
||||
const set = edit.addNode('SetVariable', { variable: 'result' });
|
||||
const set = edit.variables(['result'], { write: true });
|
||||
edit.wire([
|
||||
[start, 'exec', call, 'exec'],
|
||||
[call, 'exec', set, 'exec'],
|
||||
[call, 'out1', set, 'value'],
|
||||
[call, 'out1', set, 'result'],
|
||||
]);
|
||||
return asset;
|
||||
}
|
||||
@@ -87,13 +87,13 @@ describe('a behavior used as a node', () => {
|
||||
const start = edit.addNode(BEHAVIOR_START);
|
||||
const end = edit.addNode(BEHAVIOR_END);
|
||||
fixture.stack.execute(new AddPortCommand(callee.id, end.id, { key: 'out1', kind: 'number' }));
|
||||
const get = edit.addNode('GetVariable', { variable: 'count' });
|
||||
const get = edit.variables(['count']);
|
||||
const plus = edit.addNode('Add', { b: 1 });
|
||||
const set = edit.addNode('SetVariable', { variable: 'count' });
|
||||
const set = edit.variables(['count'], { write: true });
|
||||
edit.wire([
|
||||
[start, 'exec', set, 'exec'],
|
||||
[get, 'value', plus, 'a'],
|
||||
[plus, 'result', set, 'value'],
|
||||
[get, 'count', plus, 'a'],
|
||||
[plus, 'result', set, 'count'],
|
||||
[set, 'exec', end, 'exec'],
|
||||
[plus, 'result', end, 'out1'],
|
||||
]);
|
||||
@@ -103,12 +103,12 @@ describe('a behavior used as a node', () => {
|
||||
const onStart = cEdit.addNode('OnStart');
|
||||
const first = cEdit.addNode(RUN_BEHAVIOR, { [BEHAVIOR_PARAM]: callee.id });
|
||||
const second = cEdit.addNode(RUN_BEHAVIOR, { [BEHAVIOR_PARAM]: callee.id });
|
||||
const store = cEdit.addNode('SetVariable', { variable: 'result' });
|
||||
const store = cEdit.variables(['result'], { write: true });
|
||||
cEdit.wire([
|
||||
[onStart, 'exec', first, 'exec'],
|
||||
[first, 'exec', second, 'exec'],
|
||||
[second, 'exec', store, 'exec'],
|
||||
[second, 'out1', store, 'value'],
|
||||
[second, 'out1', store, 'result'],
|
||||
]);
|
||||
|
||||
const { ctx } = runOnStart(fixture, caller, { result: 0, count: 500 });
|
||||
@@ -135,13 +135,13 @@ describe('a behavior used as a node', () => {
|
||||
const edit = graphEditor(fixture, caller);
|
||||
const onStart = edit.addNode('OnStart');
|
||||
const call = edit.addNode(RUN_BEHAVIOR, { [BEHAVIOR_PARAM]: callee.id });
|
||||
const set = edit.addNode('SetVariable', { variable: 'result' });
|
||||
const set = edit.variables(['result'], { write: true });
|
||||
const mine = edit.addNode('Number', { value: 7 });
|
||||
edit.wire([
|
||||
[onStart, 'exec', call, 'exec'],
|
||||
// Read *after* the call, and from the caller's own node – the point of the test.
|
||||
[call, 'exec', set, 'exec'],
|
||||
[mine, 'value', set, 'value'],
|
||||
[mine, 'value', set, 'result'],
|
||||
]);
|
||||
|
||||
// Ids are unique in practice; forcing a collision is the only way to show the frames are real.
|
||||
@@ -171,7 +171,7 @@ describe('a behavior used as a node', () => {
|
||||
const edit = graphEditor(fixture, caller);
|
||||
const start = edit.addNode('OnStart');
|
||||
const call = edit.addNode(RUN_BEHAVIOR, { [BEHAVIOR_PARAM]: target });
|
||||
const set = edit.addNode('SetVariable', { variable: 'result' });
|
||||
const set = edit.variables(['result'], { write: true });
|
||||
edit.wire([
|
||||
[start, 'exec', call, 'exec'],
|
||||
// The flow carries on past the call, which is what keeps a dangling reference harmless.
|
||||
|
||||
Reference in new issue
Block a user