ProtoFlux:Async Range Loop Int: Difference between revisions

From Resonite Wiki
m Yosh moved page ProtoFlux:ASync Range Loop Int to ProtoFlux:Async Range Loop Int over redirect: ASync -> Async
cleanup
 
Line 18: Line 18:
|}}
|}}


{{Stub}}<i> Missing clarification </i>
The '''Async Range Loop Int''' node is the [[async]] analogue to the [[ProtoFlux:Range Loop Int|Range Loop Int]] node. It is used to perform looping operations by allowing one to define a range of values and step size for iterations to follow. It is a more flexible version of the [[ProtoFlux:Async For|Async For]] node.
 
Range Loop Int is a ProtoFlux node that allows for firing a bunch of executions like an [[ProtoFlux:ASync For|ASync For Loop]] except that instead of having to go one at a time from 0->count, you can specify a Start ([[Type:Int|int]]) number, End ([[Type:Int|int]]) number, and a StepSize ([[Type:Int|int]]) which all determine the range of numbers that will come out of Current ([[Type:Int|int]]) during execution and the distance between each Current ([[Type:Int|int]]) outputted.
 
This node will do a bunch of async tasks in order in an Async context, waiting for each task to be done before moving to the next one. This is useful if you want to do a bunch of [[ProtoFlux:GET String|GET String]] requests but you need to wait for the previous one to be done before doing the next, for a specified number of times. This does not behave the same as using a [[ProtoFlux:Start ASync Task|Start ASync Task]] on every [[ProtoFlux:Range Loop Int|Range Loop Int]] iteration or even before the [[ProtoFlux:Range Loop Int|Range Loop Int]] using a [[ProtoFlux:Start ASync Task|Start ASync Task]].


== Inputs ==
== Inputs ==
Line 28: Line 24:
=== * ([[Impulses#ASync|IAsyncOperation]]) ===
=== * ([[Impulses#ASync|IAsyncOperation]]) ===


Start Execution of the ASync Range Loop.
Begin the range loop.


=== Start ([[Type:Int|int]]) ===
=== Start ([[Type:Int|int]]) ===


The number to start at when executing.
The number for <code>Current</code> to start at during execution.


=== End ([[Type:Int|int]]) ===
=== End ([[Type:Int|int]]) ===


The number to end at when executing.
The number for <code>Current</code> to iterate towards and compare to during execution. This input is inclusive.


TODO: Is this inclusive or exclusive?
=== StepSize ([[Type:Int|int]]) ===


=== StepSize ([[Type:Int|int]]) ===
The value that is added or subtracted to <code>Current</code> per iteration for the current <code>LoopIteration</code>. The loop will either add or subtract this value depending on whether <code>Start</code> is less than or greater than <code>End</code>. There will be no iterations if this value is less than <code>1</code>.


How much to add to Start ([[Type:Int|int]]) per execution for the Current ([[Type:Int|int]]) output number.
{{Note|As of the time of writing, [https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/3350 this node does not account for overflow or underflow when evaluating the loop range]. To avoid this issue, make sure that <code>2147483647 - End <nowiki>&gt;=</nowiki> StepSize</code> when going forwards or <code>2147483648 + End <nowiki>&gt;=</nowiki> StepSize</code> when going backwards.|warning}}


== Outputs ==
== Outputs ==
Line 48: Line 44:
=== LoopStart ([[Impulses#ASync|AsyncCall]]) ===
=== LoopStart ([[Impulses#ASync|AsyncCall]]) ===


Fires when the loop starts, regardless of executions of the ASync Range Loop.
Fires after <code>*</code> is pulsed and before any iterations are done. Will be pulsed even if <code>StepSize < 1</code>.


=== LoopIteration ([[Impulses#ASync|AsyncCall]]) ===
=== LoopIteration ([[Impulses#ASync|AsyncCall]]) ===


Fires every time Current ([[Type:Int|int]]) increases by StepSize ([[Type:Int|int]]) and (has just or hasn't/hasn't)? hit the End ([[Type:Int|int]]) limit. Waits till the previous LoopIteration ([[Impulses#ASync|AsyncCall]]) is done or after LoopStart ([[Impulses#ASync|AsyncCall]]) is done before firing this one.
Fires for each iteration of the loop. This impulse is triggered until <code>Current</code> exceeds <code>End</code> in the direction of the loop, at which point the iterations will stop.
 
TODO: Is this inclusive or exclusive?


=== LoopEnd ([[Impulses|Continuation]]) ===
=== LoopEnd ([[Impulses|Continuation]]) ===
Line 62: Line 56:
=== Current ([[Type:Int|int]]) ===
=== Current ([[Type:Int|int]]) ===


The current number between Start ([[Type:Int|int]]) and End ([[Type:Int|int]]). has a value during every LoopIteration ([[Impulses#ASync|AsyncCall]]).
This value will start at <code>Start</code> for the first iteration, then at each iteration, this value will either increase or decrease by <code>StepSize</code> depending on whether <code>End</code> is greater than or less than <code>Start</code>. This value lasts for said iteration's entire [[context]].


== Examples ==
== Examples ==
<gallery widths=480px heights=480px>
File:Protoflux_example_ASync_Range_Loop_Int.webp|ASync Range Loop Int being used to iterate over every other character in a string using [[ProtoFlux:Get Character|Get Character]] and then calling a read cloud variable using the character.
</gallery>


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

Latest revision as of 02:55, 13 December 2024

Async Range Loop
*
LoopStart
Start
LoopIteration
End
LoopEnd
StepSize
Current
Async

The Async Range Loop Int node is the async analogue to the Range Loop Int node. It is used to perform looping operations by allowing one to define a range of values and step size for iterations to follow. It is a more flexible version of the Async For node.

Inputs

* (IAsyncOperation)

Begin the range loop.

Start (int)

The number for Current to start at during execution.

End (int)

The number for Current to iterate towards and compare to during execution. This input is inclusive.

StepSize (int)

The value that is added or subtracted to Current per iteration for the current LoopIteration. The loop will either add or subtract this value depending on whether Start is less than or greater than End. There will be no iterations if this value is less than 1.

As of the time of writing, this node does not account for overflow or underflow when evaluating the loop range. To avoid this issue, make sure that 2147483647 - End >= StepSize when going forwards or 2147483648 + End >= StepSize when going backwards.

Outputs

LoopStart (AsyncCall)

Fires after * is pulsed and before any iterations are done. Will be pulsed even if StepSize < 1.

LoopIteration (AsyncCall)

Fires for each iteration of the loop. This impulse is triggered until Current exceeds End in the direction of the loop, at which point the iterations will stop.

LoopEnd (Continuation)

Fires once the loop has finished.

Current (int)

This value will start at Start for the first iteration, then at each iteration, this value will either increase or decrease by StepSize depending on whether End is greater than or less than Start. This value lasts for said iteration's entire context.

Examples