For Loop With Break

| Inputs | |
|---|---|
| First Index | Starting value for Index will be assigned. |
| Last Index | Final value Index reaches for loop completion. |
| Break | Execution pin to exit loop. |
| Outputs | |
|---|---|
| Loop Body | Execution Pulse for each iteration of the loop. |
| Index | Current iteration counter the loop is on. |
| Completed | Execution Pulse after the loop has reached the Last Index and finished the Loop Body pulse. |
Overview
For Loop With Break will perform a series of runs for the designated amount of times unless exited early.
The starting and final values can be modified, and the current loop counter can be tracked with Index. At the start of each iteration, the Loop Body pin pulses to run the logic of the loop. On the last iteration, after Loop Body finishes, Completed will pulse.
This works like your standard For Loop in C++, except slightly more rigid. Where the incrementing occurs and the finished condition cannot be changed.
However, unlike the For Loop node, you can exit early using the Break pin.
Warnings
The entire loop will run in a single linear flow when executing. In most cases, the loop has to finish before any other logic runs unless exited with break.
If the iteration count of the loop is very high or the logic inside it is heavy, it could cause performance problems.
Examples
Damage Rolling
This will roll nine times for a random damage amount between 0 and 12 and subtract it from health. If health is reduced to zero or below, it is set to zero, and the loop exits early.



