ProtoFlux:For: Difference between revisions

From Resonite Wiki
Added node information
m fix types
 
(4 intermediate revisions by 3 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":"Continuation"},
{"Name": "LoopEnd", "Type":"Continuation"},
{"Name": "iteration", "Type":"int"}
{"Name": "iteration", "Type":"int"}
Line 18: Line 18:
The For node is used to perform looping operations. allowing to fire impulses a set amount of times. As well as outputting the current iteration count.
The For node is used to perform looping operations. allowing to fire impulses a set amount of times. As well as outputting the current iteration count.


For the async variant. See [[ASync For (ProtoFlux)|Async For]]
For the async variant. See [[ProtoFlux:ASync For|Async For]]


== Inputs ==
== Inputs ==


=== * (Call) ===  
=== * ([[Impulses|Call]]) ===  


When an impulse is received. It triggers the for node. Starting the loop.
When an impulse is received. It triggers the for node. Starting the loop.
Line 32: Line 32:
=== Reverse ([[Type:Bool|Bool]]) ===
=== Reverse ([[Type:Bool|Bool]]) ===


Controls whether the <code>Iteration</code> increases or decreases for each <code>LoopIteration</code>. The default is False.
Controls whether the <code>Iteration</code> increases or decreases for each <code>LoopIteration</code>. The default is false.


== Outputs ==
== Outputs ==


=== LoopStart (Call) ===
=== LoopStart ([[Impulses|Call]]) ===


Fires once immediately after <code>*</code> is pulsed. completing the connected node chain before the loop starts and any impulses are fired from <code>LoopIteration</code>. Allowing for operations to be done before the loop.
Fires once immediately after <code>*</code> is pulsed. completing the connected node chain before the loop starts and any impulses are fired from <code>LoopIteration</code>. Allowing for operations to be done before the loop.


=== LoopIteration (Call) ===
=== LoopIteration ([[Impulses|Call]]) ===


Fires impulses sequentially until the total amount equals <code>Count</code>. No impulses will be fired if <code>Count</code> is 0 or a negative number. the impulse chain will complete before the next <code>LoopIteration</code> is fired. unless there is any type of async delay in the chain. causing it to execute up until the delay before firing the next impulse.
Fires impulses sequentially until the total amount equals <code>Count</code>. No impulses will be fired if <code>Count</code> is 0 or a negative number. the impulse chain will complete before the next <code>LoopIteration</code> is fired. unless there is any type of async delay in the chain. causing it to execute up until the delay before firing the next impulse.


=== LoopEnd (Continuation) ===
=== LoopEnd ([[Impulses|Continuation]]) ===


Fires once after the loop is completed. Allowing the execution chain to continue. Allowing for operations to be done after the loop has been completed.
Fires once after the loop is completed. Allowing the execution chain to continue. Allowing for operations to be done after the loop has been completed.
Line 50: Line 50:
=== Iteration ([[Type:Int|Int]]) ===
=== Iteration ([[Type:Int|Int]]) ===


Outputs the current iteration of the loop. Updates every time `LoopIteration` is fired. If `Reverse` is false. Iteration will start at 0 and increase each loop. ending at <code>Count</code> - 1. If `Reverse` is true. it will start at <code>Count</code> - 1 and decrease each loop. ending at 0.
Outputs the current iteration of the loop. Updates every time <code>LoopIteration</code> is fired. If <code>Reverse</code> is false. Iteration will start at 0 and increase each loop. ending at <code>Count - 1</code>. If <code>Reverse</code> is true. it will start at <code>Count - 1</code> and decrease each loop. ending at 0.


If <code>Count</code> is '''5''' and <code>Reverse</code> is '''false'''. The iteration during the loop would be <code>0, 1, 2, 3, 4</code>
If <code>Count</code> is '''5''' and <code>Reverse</code> is '''false'''. The iteration during the loop would be <code>0, 1, 2, 3, 4</code>
Line 57: Line 57:


== Examples ==
== 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>
[[Category:ProtoFlux:Flow]]
[[Category:ProtoFlux:Flow]]

Latest revision as of 20:15, 9 February 2024

For
*
LoopStart
Count
LoopIteration
Reverse
LoopEnd
iteration
Flow

The For node is used to perform looping operations. allowing to fire impulses a set amount of times. As well as outputting the current iteration count.

For the async variant. See Async For

Inputs

* (Call)

When an impulse is received. It triggers the for node. Starting the loop.

Count (Int)

sets the number of iterations the for loop will run for. The count is evaluated before the LoopStart impulse is fired and the count cannot be changed during the loop. The default is 0.

Reverse (Bool)

Controls whether the Iteration increases or decreases for each LoopIteration. The default is false.

Outputs

LoopStart (Call)

Fires once immediately after * is pulsed. completing the connected node chain before the loop starts and any impulses are fired from LoopIteration. Allowing for operations to be done before the loop.

LoopIteration (Call)

Fires impulses sequentially until the total amount equals Count. No impulses will be fired if Count is 0 or a negative number. the impulse chain will complete before the next LoopIteration is fired. unless there is any type of async delay in the chain. causing it to execute up until the delay before firing the next impulse.

LoopEnd (Continuation)

Fires once after the loop is completed. Allowing the execution chain to continue. Allowing for operations to be done after the loop has been completed.

Iteration (Int)

Outputs the current iteration of the loop. Updates every time LoopIteration is fired. If Reverse is false. Iteration will start at 0 and increase each loop. ending at Count - 1. If Reverse is true. it will start at Count - 1 and decrease each loop. ending at 0.

If Count is 5 and Reverse is false. The iteration during the loop would be 0, 1, 2, 3, 4

And if Reverse is true. The iteration would be 4, 3, 2, 1, 0

Examples