Difference between revisions of "For (LogiX node)"

From Neos Wiki
Jump to navigation Jump to search
 
(13 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
<languages></languages>
 
<languages></languages>
 
<translate>
 
<translate>
The '''For''' node fires impulses from LoopInteration equal to the number of iterations specified by the Count input. For the duration of the impulse chain started by each LoopIteration impulse the Iteration value is equal to the iteration number. An impulse is fired from LoopStart before iterations begin and from LoopEnd after iterations have completed.
+
<!--T:1-->
 +
{{Infobox Logix Node
 +
| Name = For
 +
| Image =[[File: ForNodeNode.png | noframe | 128px | 'For' LogiX node ]]
 +
| Input0Type = Impulse | Input0Name = Run
 +
| Input1Type = Int | Input1Name = Count
 +
| Input2Type = Bool | Input2Name = Reverse
 +
| Output0Type = Impulse | Output0Name = LoopStart
 +
| Output1Type = Impulse | Output1Name = LoopIteration
 +
| Output2Type = Impulse | Output2Name = LoopEnd
 +
| Output3Type = Int | Output3Name = Iteration
 +
}}
  
<!--[[File:|border|256px|right]]-->
+
<!--T:2-->
 +
The '''For''' node is used to fire impulses from the <code>LoopIteration</code> output a specific number of times when an impulse is received at <code>Run</code>.
  
== Inputs & Outputs ==
+
== Usage == <!--T:3-->
{| class="wikitable"
+
* The <code>Count</code> input determines how many times impulses will be fired from the <code>LoopIteration</code> output. The default is 0. This count, is evaluated immediately after the <code>LoopStart</code> impulse chain has completed, just before any impulses are fired from <code>LoopIteration</code>.
|+Inputs
 
|-
 
| Color
 
| Label
 
| Type
 
|-
 
| style="background-color:{{Impulse-color}}" |
 
| Run
 
| [[:LogiX:Impulses|Impulse]]
 
|-
 
| style="background-color:{{Int-color}}" |
 
| Count
 
| [[:Category:Types:Integer|Integer]]
 
|}
 
  
{| class="wikitable"
+
<!--T:6-->
|+Outputs
+
* The <code>Reverse</code> input controls if the <code>Iteration</code> output value is incremented or decremented each <code>LoopIteration</code>. The default is False, meaning <code>Iteration</code> is incremented each iteration.
|-
 
| Color
 
| Label
 
| Type
 
|-
 
| style="background-color:{{Impulse-color}}" |
 
| LoopStart
 
| [[:LogiX:Impulses|Impulse]]
 
|-
 
| style="background-color:{{Impulse-color}}" |
 
| LoopIteration
 
| [[:LogiX:Impulses|Impulse]]
 
|-
 
| style="background-color:{{Impulse-color}}" |
 
| LoopEnd
 
| [[:LogiX:Impulses|Impulse]]
 
|-
 
| style="background-color:{{Int-color}}" |
 
| Iteration
 
| [[:Category:Types:Integer|Integer]]
 
|}
 
  
== Usage ==
+
<!--T:7-->
Neos uses zero indexing, hence the Iteration value for the first impulse fired from LoopImpuse is zero. Iteration values will increase up to Count - 1. All iterations for this node complete within a single frame update - if this does not complete within the time normally taken for a frame update it produces visible framerate hitches. There is a timeout which puts this node into an error state (visual turns red) if it delays an update excessively to prevent complete freezes.
+
* The <code>LoopStart</code> output fires an impulse once after an impulse is received at <code>Run</code>. This impulse chain will complete before any impulses are fired from <code>LoopIteration</code>.
== Examples ==
+
 
The For node is extremely useful for looping a known number of times. If similar looping behavior is required, but the number of required iterations cannot be determined prior to starting the loop, consider using the [[While (LogiX node)|While]] node.
+
<!--T:8-->
== Node Menu ==
+
* The <code>LoopIteration</code> output fires impulses sequentially until the total number which have been fired is equal to the <code>Count</code> input. Each impulse chain started from <code>LoopIteration</code> completes before the following one is fired. Nodes which [[Logix:Impulse Splitting|split the chain]] will cause the For node to continue with subsequent iterations without waiting for the split chain's completion.
 +
 
 +
<!--T:9-->
 +
* The <code>LoopEnd</code> output fires an impulse once the final impulse chain started from <code>LoopIteration</code> has ended.
 +
 
 +
<!--T:10-->
 +
* The <code>Iteration</code> output value is either incremented or decremented each time a new impulse is fired from <code>LoopIteration</code>, depending on the value of <code>Reverse</code>. If <code>Reverse</code> is False, <code>Iteration</code> is incremented each time an impulse is fired from <code>LoopIteration</code> starting with the value 0, during the first iteration, and ending with <code>Count</code> - 1 on the final iteration. If <code>Reverse</code> is True, the <code>Iteration</code> value is <code>Count</code> - 1 on the first iteration and decremented each time down to 0 on the final iteration.
 +
 
 +
<!--T:11-->
 +
Impulse chains started from this node effectively continue the one which arrived at <code>Run</code>, meaning that any temporary values from previous nodes are still available. All iterations from <code>LoopIteration</code> complete within a single frame update and therefore this can produce framerate hitches if an excessively demanding computation is performed. There is a failsafe which will put this node into an error state (node visual turns red) if a frame is delayed excessively - this helps prevent complete freezes.
 +
 
 +
== Examples == <!--T:4-->
 +
 
 +
== Node Menu == <!--T:5-->
 
</translate>
 
</translate>
  
[[Category:LogiX|For]]
+
[[Category:LogiX{{#translation:}}|For]]
[[Category:LogiX: Flow|For]]
+
[[Category:LogiX:Flow{{#translation:}}|For]]
 
{{:NodeMenu-Flow}}
 
{{:NodeMenu-Flow}}

Latest revision as of 01:31, 7 November 2022

Other languages:
English • ‎日本語
For
'For' LogiX node
Inputs
  Impulse Run
  Int Count
  Bool Reverse
Outputs
  Impulse LoopStart
  Impulse LoopIteration
  Impulse LoopEnd
  Int Iteration

The For node is used to fire impulses from the LoopIteration output a specific number of times when an impulse is received at Run.

Usage

  • The Count input determines how many times impulses will be fired from the LoopIteration output. The default is 0. This count, is evaluated immediately after the LoopStart impulse chain has completed, just before any impulses are fired from LoopIteration.
  • The Reverse input controls if the Iteration output value is incremented or decremented each LoopIteration. The default is False, meaning Iteration is incremented each iteration.
  • The LoopStart output fires an impulse once after an impulse is received at Run. This impulse chain will complete before any impulses are fired from LoopIteration.
  • The LoopIteration output fires impulses sequentially until the total number which have been fired is equal to the Count input. Each impulse chain started from LoopIteration completes before the following one is fired. Nodes which split the chain will cause the For node to continue with subsequent iterations without waiting for the split chain's completion.
  • The LoopEnd output fires an impulse once the final impulse chain started from LoopIteration has ended.
  • The Iteration output value is either incremented or decremented each time a new impulse is fired from LoopIteration, depending on the value of Reverse. If Reverse is False, Iteration is incremented each time an impulse is fired from LoopIteration starting with the value 0, during the first iteration, and ending with Count - 1 on the final iteration. If Reverse is True, the Iteration value is Count - 1 on the first iteration and decremented each time down to 0 on the final iteration.

Impulse chains started from this node effectively continue the one which arrived at Run, meaning that any temporary values from previous nodes are still available. All iterations from LoopIteration complete within a single frame update and therefore this can produce framerate hitches if an excessively demanding computation is performed. There is a failsafe which will put this node into an error state (node visual turns red) if a frame is delayed excessively - this helps prevent complete freezes.

Examples

Node Menu

Flow
Back Events Boolean Latch Delay Delay With Value Dynamic Impulse Receiver Dynamic Impulse Receiver With Value`1
Dynamic Impulse Trigger Dynamic Impulse Trigger With Value`1 Fire On Change Fire On False Fire On True Fire While True For
If Impulse Demultiplexer Impulse Multiplexer Local Fire On Change`1 Local Fire On False Local Fire On True Local Impulse Timeout
Local Leaky Impulse Bucket One Per Frame Pulse Random Sequence Timer Update Updates Delay
Updates Delay With Value While