ProtoFlux:For: Difference between revisions

From Resonite Wiki
add for loop
 
move async link to see also
 
(8 intermediate revisions by 5 users not shown)
Line 4: Line 4:
|Inputs=
|Inputs=
[
[
{"Name": "*", "Type": "Impulse"},
{"Name": "*", "Type": "Call"},
{"Name": "Count", "Type": "int"},
{"Name": "Count", "Type": "int"},
{"Name": "Reverse", "Type": "bool"}
{"Name": "Reverse", "Type": "bool"}
Line 10: Line 10:
|Outputs=
|Outputs=
[
[
{"Name": "LoopStart", "Type":"Impulse"},
{"Name": "LoopStart", "Type":"Call"},
{"Name": "LoopIteration", "Type":"Impulse"},
{"Name": "LoopIteration", "Type":"Call"},
{"Name": "LoopEnd", "Type":"AsyncImpulse"},
{"Name": "LoopEnd", "Type":"Continuation"},
{"Name": "iteration", "Type":"int"}
{"Name": "iteration", "Type":"int"}
]
]
|}}
|}}
The '''For''' node is used to perform looping operations by allowing one to fire impulses a set amount of times.
== Inputs ==
=== * ([[Impulses|Call]]) ===
Begin the for loop.
=== 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]]) ===
If <code>True</code>, the <code>Iteration</code> output will start at <code>Count - 1</code> and go down towards <code>0</code>.
== Outputs ==
=== LoopStart ([[Impulses|Call]]) ===
Fires after <code>*</code> is pulsed and before any iterations are done. Will be pulsed even if <code>Count < 1</code>.
=== LoopIteration ([[Impulses|Call]]) ===
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]]) ===
Fires after the final <code>LoopIteration</code> completes execution.
=== 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">
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>
== See Also ==
* [[ProtoFlux:Async For]] for the [[async]] variant of this node.


[[Category:ProtoFlux:Flow]]
[[Category:ProtoFlux:Flow]]

Latest revision as of 19:11, 15 December 2024

For
*
LoopStart
Count
LoopIteration
Reverse
LoopEnd
iteration
Flow

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

See Also