Change Variable β
Set, add to or subtract from a user variable while the item runs.
Requires [add-on] - Conditions & Variables - 1Click inside the object that runs the action.
Change Variable updates a user variable at that point in the function. It is how state changes: a toggle flips, a counter grows, a mode is stored.
Fields β
| Field | Required | What to enter |
|---|---|---|
Variable | Yes | The user variable to change (dropdown). |
Action | Yes | Set (=) replaces the value. Add (+) and Subtract (β) work on Integer and Float variables only. |
Value | Yes | A literal value of the variableβs type, or another variable ($other, or a system variable such as !touched_key). |
Examples β
| Goal | Variable | Action | Value |
|---|---|---|---|
| Turn a state on | $light (string) | Set | ON |
| Count clicks | $clicks (integer) | Add | 1 |
| Step back | $page (integer) | Subtract | 1 |
| Remember who clicked | $last_user (key) | Set | !touched_key |
| Copy a value | $a | Set | $b |
Type rules β
The value must match the variable's type: text into strings, numbers into integers/floats, <x,y,z> into vectors, UUIDs into keys. Add/Subtract on a string does nothing.
Timing β
A change is applied a few milliseconds after the action runs. If the very next action is a condition on the same variable, put a Timer of 0.1 seconds between them, otherwise the condition may still read the old value. In normal flows (change on one click, compare on the next) this never matters.
In a toggle, put the Change Variable first in each branch, before the actions people see. The actions of a function run one after the other and each takes a moment in Second Life; with the change at the end, a quick second click can still read the old value and run the same branch twice.
Where it runs β
The variable lives in the object running the function. A HUD cannot change a variable inside a target directly; send a command and let the target's own function change its variable.