Skip to main content

Counter

This node maintains a numeric count that can be increased, decreased, or reset.

The Counter node is a stateful utility for tracking numbers, scores, or iterations.

The Counter node stores a current count value. It provides simple actions to increment or decrement this value, along with optional limits (min/max) to constrain the range. It is simpler than using a Variable + Addition node loop for basic counting tasks.

Inputs

Actions

SignalDescription
Increase CountAdds 1 to the current count.
Decrease CountSubtracts 1 from the current count.
Reset To StartResets the count to the value specified in Start Value.

Configuration

DataDescription
Start ValueThe initial value of the counter. Also used when resetting. Default: 0.

Limits

DataDescription
Limits EnabledBoolean flag. If true, the counter will not go below Min Value or above Max Value.
Min ValueThe minimum allowed value (inclusive) when limits are enabled.
Max ValueThe maximum allowed value (inclusive) when limits are enabled.

Outputs

Data

DataDescription
Current CountThe current value of the counter.

Signals

SignalDescription
Count ChangedTriggered whenever the count value changes.

Usage

Example Use Cases

  1. Scoreboard: Track player points.
    • Connect "Point Scored" signal to Increase Count.
    • Connect Current Count to a Text node.
  2. Inventory Quantity: Track number of items.
    • Enable Limits.
    • Set Min Value to 0 (cannot have negative items).
    • Set Max Value to 99 (stack limit).
  3. Pagination: Track current page number.
    • Start Value: 1.
    • Increase Count: Next Page button.
    • Decrease Count: Previous Page button.

Detailed Behavior

  1. Initialization:
    • When the node loads, Current Count is set to Start Value.
    • Count Changed fires immediately on initialization if Start Value is set via connection.
  2. Limits:
    • If Limits Enabled is true:
      • Increase Count does nothing if Current Count >= Max Value.
      • Decrease Count does nothing if Current Count <= Min Value.
    • If limits are disabled, the counter can grow/shrink indefinitely (within JS number limits).
  3. Reset:
    • Reset To Start sets Current Count = Start Value.
    • It only fires Count Changed if the value actually changed (i.e., it wasn't already at the start value).

Troubleshooting

  • Counter Stuck: Check if Limits Enabled is true and if you have reached the Min or Max value.
  • Reset Not Working: Ensure Start Value is set to what you expect.