m fix types |
make more concise, matching async for |
||
Line 16: | Line 16: | ||
] | ] | ||
|}} | |}} | ||
For the async variant | The '''For''' node is used to perform looping operations by allowing one to fire impulses a set amount of times. | ||
For the [[async]] variant of this node, see [[ProtoFlux:Async For|Async For]]. | |||
== Inputs == | == Inputs == | ||
=== * ([[Impulses|Call]]) === | === * ([[Impulses|Call]]) === | ||
Begin the for loop. | |||
=== Count ([[Type:Int|Int]]) === | === Count ([[Type:Int|Int]]) === | ||
The amount of times to trigger <code>LoopIteration</code>. Will not trigger any iterations if less than 1. | |||
=== Reverse ([[Type:Bool|Bool]]) === | === Reverse ([[Type:Bool|Bool]]) === | ||
If <code>True</code>, the <code>Iteration</code> output will start at <code>Count - 1</code> and go down towards <code>0</code>. | |||
== Outputs == | == Outputs == | ||
Line 38: | Line 39: | ||
=== LoopStart ([[Impulses|Call]]) === | === LoopStart ([[Impulses|Call]]) === | ||
Fires | Fires after <code>*</code> is pulsed and before any iterations are done. Will be pulsed even if <code>Count < 1</code>. | ||
=== LoopIteration ([[Impulses|Call]]) === | === LoopIteration ([[Impulses|Call]]) === | ||
Fires | Fires for each iteration of the loop. This impulse is triggered <count>Count</code> amount of times and the next iteration will only be fired once the current iteration's [[context]] is finished. | ||
=== LoopEnd ([[Impulses|Continuation]]) === | === LoopEnd ([[Impulses|Continuation]]) === | ||
Fires | Fires after the final <code>LoopIteration</code> completes execution. | ||
=== Iteration ([[Type:Int|Int]]) === | === Iteration ([[Type:Int|Int]]) === | ||
For each <code>LoopIteration</code>, this output is set to be the index of the iteration for said iteration's context. By default, this will start at <code>0</code> and increment until <code>Count - 1</code> unless <code>Reverse</code> is <code>True</code>. | |||
== Examples == | |||
<gallery widths="480" heights="480"> | <gallery widths="480" heights="480"> | ||
File:For node example.png|Using the '''for''' node to iteratively check if a child slot has the tag 'foo'. and replace it with 'bar' using the [[Children Count (ProtoFlux)|Children Count]] and [[Get Child (ProtoFlux)|Get Child]] nodes. | File:For node example.png|Using the '''for''' node to iteratively check if a child slot has the tag 'foo'. and replace it with 'bar' using the [[Children Count (ProtoFlux)|Children Count]] and [[Get Child (ProtoFlux)|Get Child]] nodes. | ||
</gallery> | </gallery> | ||
[[Category:ProtoFlux:Flow]] | [[Category:ProtoFlux:Flow]] |
Revision as of 21:53, 12 December 2024
The For node is used to perform looping operations by allowing one to fire impulses a set amount of times.
Inputs
* (Call)
Begin the for loop.
Count (Int)
The amount of times to trigger LoopIteration
. Will not trigger any iterations if less than 1.
Reverse (Bool)
If True
, the Iteration
output will start at Count - 1
and go down towards 0
.
Outputs
LoopStart (Call)
Fires after *
is pulsed and before any iterations are done. Will be pulsed even if Count < 1
.
LoopIteration (Call)
Fires for each iteration of the loop. This impulse is triggered <count>Count amount of times and the next iteration will only be fired once the current iteration's context is finished.
LoopEnd (Continuation)
Fires after the final LoopIteration
completes execution.
Iteration (Int)
For each LoopIteration
, this output is set to be the index of the iteration for said iteration's context. By default, this will start at 0
and increment until Count - 1
unless Reverse
is True
.
Examples
-
Using the for node to iteratively check if a child slot has the tag 'foo'. and replace it with 'bar' using the Children Count and Get Child nodes.