add async while |
m Yosh moved page ProtoFlux:ASync While to ProtoFlux:Async While: ASync -> Async |
||
(7 intermediate revisions by 4 users not shown) | |||
Line 4: | Line 4: | ||
|Inputs= | |Inputs= | ||
[ | [ | ||
{"Name": "*", "Type": " | {"Name": "*", "Type": "AsyncCall"}, | ||
{"Name": "Condition", "Type": "bool"} | {"Name": "Condition", "Type": "bool"} | ||
] | ] | ||
|Outputs= | |Outputs= | ||
[ | [ | ||
{"Name": "LoopStart", "Type":" | {"Name": "LoopStart", "Type":"AsyncCall"}, | ||
{"Name": "LoopIteration", "Type":" | {"Name": "LoopIteration", "Type":"AsyncCall"}, | ||
{"Name": "LoopEnd", "Type":"Continuation"} | {"Name": "LoopEnd", "Type":"Continuation"} | ||
] | ] | ||
|}} | |}} | ||
The '''Async While''' node is the [[async]] variant of the [[ProtoFlux:While|While]] node. It is used to perform looping operations by allowing one to fire [[impulses]] continuously while a condition remains true. | |||
{{Note|Be very careful when developing with this node. [https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/774 There is no iteration limit for debugging] and [https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/1677 ProtoFlux does not have handling for execution taking too long]. If you accidentally create an infinite loop without any [[ProtoFlux:Delay|delays]], you'll be unable to save progress or anything else important. Consider adding your own iteration limit, not being connected to an input impulse while developing, and save before testing!|danger}} | |||
== Inputs == | |||
=== * ([[Impulses#ASync|IAsyncOperation]]) === | |||
Begin the while loop. | |||
=== Condition ([[Type:Bool|bool]]) === | |||
Condition that the loop will check to determine if it should iterate again or not. If <code>True</code>, it will iterate again. | |||
== Outputs == | |||
=== LoopStart ([[Impulses#ASync|AsyncCall]]) === | |||
Fires after <code>*</code> is pulsed and before any iterations are performed. Will be pulsed even if <code>Condition</code> is <code>False</code> at the time of the loop beginning. | |||
=== LoopIteration ([[Impulses#ASync|AsyncCall]]) === | |||
Will be pulsed for as long <code>Condition</code> is <code>True</code>. Only after the [[context]] of the current loop iteration is finished will the next iteration fire. | |||
=== LoopEnd ([[Impulses|Continuation]]) === | |||
Fires after <code>Condition</code> turns <code>False</code>, continuing the impulse chain from before. | |||
== Known Issues == | |||
* As of the time of writing, there is [https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/256 a known issue] where if the final node in the <code>LoopIteration</code> chain is a [[ProtoFlux:Write|Write]] node, said node modifies a variable used for conditional evaluation, <em>and</em> the value to write is based off said variable, the write will be using a previously cached value. This can cause an extra loop iteration to occur, which is very annoying to debug. | |||
** The easiest way to work around this bug is to add a "dummy" node after the write, such as an [[ProtoFlux:Impulse Display|Impulse Display]] or, if debugging a ton of impulses and lag is undesirable, an empty Write node. | |||
== See Also == | |||
* If it is possible to determine the amount of times you need to loop beforehand, consider [[ProtoFlux:Async For]] instead. | |||
[[Category:ProtoFlux:Flow:Async]] | [[Category:ProtoFlux:Flow:Async]] |
Latest revision as of 19:27, 15 December 2024
Async While
Async
The Async While node is the async variant of the While node. It is used to perform looping operations by allowing one to fire impulses continuously while a condition remains true.
Inputs
* (IAsyncOperation)
Begin the while loop.
Condition (bool)
Condition that the loop will check to determine if it should iterate again or not. If True
, it will iterate again.
Outputs
LoopStart (AsyncCall)
Fires after *
is pulsed and before any iterations are performed. Will be pulsed even if Condition
is False
at the time of the loop beginning.
LoopIteration (AsyncCall)
Will be pulsed for as long Condition
is True
. Only after the context of the current loop iteration is finished will the next iteration fire.
LoopEnd (Continuation)
Fires after Condition
turns False
, continuing the impulse chain from before.
Known Issues
- As of the time of writing, there is a known issue where if the final node in the
LoopIteration
chain is a Write node, said node modifies a variable used for conditional evaluation, and the value to write is based off said variable, the write will be using a previously cached value. This can cause an extra loop iteration to occur, which is very annoying to debug.- The easiest way to work around this bug is to add a "dummy" node after the write, such as an Impulse Display or, if debugging a ton of impulses and lag is undesirable, an empty Write node.
See Also
- If it is possible to determine the amount of times you need to loop beforehand, consider ProtoFlux:Async For instead.