Change Broadcaster Variable
Runs on: Backend -- changes the value in one step on the server.
The Change Broadcaster Variable effect adds to or subtracts from a Streamer Variable that holds a number or a degrading number.
It changes the value in one step on the server, so events that land at the same moment never overwrite each other's change. This is the safe way to build counters, points and countdowns. If you read the value with a Broadcaster Variable node, add with a Math node, and write it back with Set Broadcaster Variable, two events in the same instant can both read the old value, and one change is lost.
Configuration
- Variable (required): the variable to change. Only Number and Degrading number variables are listed.
- Operation: Add or Subtract.
- Minimum: tick the box to set a lowest value. When it is off, the field shows "No limit" and is disabled.
- Maximum: tick the box to set a highest value. When it is off, the field shows "No limit" and is disabled.
Limits only stop movement in the direction it is going. If a value is already above the Maximum, Add will not pull it back down.
For a degrading number, the change is added to the current (already decayed) value, and the decay keeps ticking smoothly.
Inputs
| Name | Type | Description |
|---|---|---|
Activate | pulse | Optional. Fires the effect even when every other input is typed in. |
Amount | number | How much to add or subtract. A connected input wins over the typed value. A negative amount under Add subtracts. |
Outputs
| Name | Type | Description |
|---|---|---|
Value | number | The new value of the variable. |
Then | pulse | Fires after the effect runs. Wire it into another effect's Activate to sequence them. |
The effect fails, and writes nothing, if the variable is missing, is not a number or degrading number, the amount is not a number, or the Minimum is above the Maximum.
Example
Count every death with a deaths Number variable. Add a Chat Command trigger for death and a Change Broadcaster Variable effect set to deaths, Add, Amount 1. Wire its Value output into a Generate Text node and send it to chat.
To convert before changing, put an Advanced Math node in front of Amount. For example, round(a * 0.6) turns bits into whole seconds for a Countdown Timer.