incrementBefore
A function node that simulates the pre-increment operator (++a). It first adds 1 to the input variable and then returns the new, updated value.
Core Advantages
Provides an atomic 'increment-then-get' operation, mimicking the familiar `++i` programming paradigm. This makes logic that requires 1-based counting or avoiding a zero-index more concise and intentional, eliminating the need for boilerplate code like `index + 1`.
Common Uses
Implementing 1-based loop counting.
Accessing arrays or resources while skipping a reserved 0-index.
Avoiding the disappearance of the first element in procedural generation due to multiplication by zero.
Counting events to intuitively get '1st', '2nd', etc., occurrences.
How to adjust
The node's behavior is fixed. Its main visual difference from `increment` lies in the returned sequence. For example, in a striped pattern driven by a counter, using `incrementBefore` will cause the first stripe's brightness value to start at 1 instead of 0. This avoids a pure black initial stripe and shifts the entire pattern's starting brightness up by one step.
Code Examples
1// myCounter is a mutable node, e.g., VarNode(0)
2const newValue = incrementBefore( myCounter );
3
4// At this point, both newValue and myCounter's internal value are now 1.