Skip to reading
Visual Scripting in Depth

30. Repeat a counted sequence with For Loop

Edition 0.86.4.3

0.86.4.3 edition with revised lessons, updated cross-references and new cinematic/camera-safety supplements. Earlier examples, screenshots and registry figures retain their stated edition context.

Download PDFView illustrations

Figure 21. For Loop has LOOP and DONE outputs. The body must return to the loop node.

1. Create pulse_count and loop_index as number variables.

2. Set pulse_count to 0 before entering the loop.

3. Add For Loop. Set Iterations to 3 and Index Variable to loop_index.

4. Connect LOOP to Change Variable: pulse_count add 1.

5. Continue through a visible beacon on/off sequence, with a short Wait after each change.

6. Connect the last body node back to For Loop FLOW. Connect DONE to a final restore or Return node.

Source table from 30. Repeat a counted sequence with For Loop, page 34
VisitIndex / behavior
First bodyloop_index = 0
Second bodyloop_index = 1
Third bodyloop_index = 2
Next visit to For LoopDONE; the body no longer runs.

The loop counter belongs to this graph invocation and loop-node ID. The Index Variable is a runtime variable you can inspect or use. At the end of a three-iteration loop, its last written index is 2; it is not automatically changed to 3.

Without the return wire, the body runs once and the graph follows whatever route you connected after it. The loop node must be revisited to decide whether another iteration is due.

Page 34 of 93Permalink
Go to page