For Start
Start point of a for-each loop over elements.
What it does
For Start opens a loop. Pair it with a For End node downstream, and everything between them runs once per iteration. Loop Mode sets what drives the loop: For repeats the body a fixed number of times, set by Count, while For Each walks through whatever is wired into Collection: a list, a string, a number array, or any collection of points, shapes, or other entities.
In For Each mode the node outputs the current item on each pass along with $index, the 0-based iteration number. What an iteration receives depends on the input: a list gives one element at a time, a string one character, a number array one number, and any other collection one entity (or one partition's worth of entities) per iteration. Once the loop finishes, result carries the output For End accumulated across all iterations.
When to use it
Repeating an operation a fixed number of times → Loop Mode: For, set Count.
Processing every element of a list, every character of a string, every number in a number array, or every point or shape in a collection → Loop Mode: For Each, wired into Collection.
Per-iteration index or item values feeding the loop body: read $index and item off For Start.
The loop's final combined output: take it from result, after wiring the matching For End.
| Parameter | Type | Default |
|---|---|---|
loop_mode | String | "For Each" |
count | Number | 10 |
collection | OneOf([Collection, Collection, String]) | — |
strength | Number | 1 |
Gotchas
In For mode there is no item to read, only $index. The item output carries values in For Each mode only.
What counts as one item for a collection depends on how it is grouped upstream. Normally each iteration receives one entity, but if an upstream node has partitioned the collection, each iteration receives that whole partition's worth of entities together.
Collection is required in For Each mode, but leaving it unwired does not error. A freshly placed For Start idles with empty outputs until something is connected. It becomes a hard error only if a save file loses that wire on load.
Worked example
Add a For Start and a matching For End further along the graph.
Set Loop Mode. For a fixed repeat count, choose For and set Count. To walk through data, choose For Each.
In For Each mode, wire a list, string, number array, or collection into Collection.
Build the loop body between the two nodes, reading item and $index from For Start as needed.
Read the finished output from result on either node once the loop has run through every iteration.