'Action: Set Variable'

The Set Variable action modifies a variable's value. Variables are the backbone of interactive logic — they track scores, count attempts, remember choices, and control what participants see. Every time you need your Ripple to "remember" something, you'll use this action.

Operations

Set

Assigns a specific value to the variable. The new value replaces whatever was there before.

Example: Set $currentAnswer to "Paris" when a participant clicks an answer button.

Add

Adds a value to the current number. For strings, concatenates text.

Example: Add 1 to $score each time a correct answer is given.

Subtract

Subtracts a value from the current number. Only works with number variables.

Example: Subtract 1 from $lives when a participant makes a mistake.

Toggle

Flips a boolean variable between true and false. For number variables, toggles between 0 and 1.

Example: Toggle $soundEnabled when a participant clicks the mute button.

Random

Generates a random integer between a minimum and maximum value (inclusive). This is surprisingly powerful for games and interactive content.

Example: Set $diceRoll to a random number between 1 and 6.

Random has three modes:

  • Cycle: Uses each value exactly once before repeating. Like shuffling a deck — fair rotation through all possibilities.
  • No Repeat: Never picks the same value twice in a row. Less strict than Cycle, but prevents immediate repeats.
  • Pure Random: True randomness with no restrictions. Values can repeat at any time.

The min and max values can also reference other variables — for example, set max to $sys.participantCount to generate a random number based on how many people are in the Ripple.

Reset All

Resets all variables in the Ripple to their default values. This is a nuclear option — use it for "start over" or "try again" buttons.

Variable References

The value field can reference another variable instead of a literal value. Enable variable reference mode and enter a variable name like $otherScore. The action will use that variable's current value.

Example: Set $highScore to the value of $currentScore when the game ends.

Scope: Local vs Global

  • Local (default): Only the triggering user's copy of the variable changes. Each participant has their own independent variable state.
  • Global: The variable changes for everyone in the Ripple simultaneously. The update is broadcast in real-time via the data channel. Any participant can trigger global variable changes — this is safe by design since the creator controls what variables exist and how they're modified.

Global variables are essential for:

  • Shared scoreboards
  • Collaborative counters
  • Voting systems
  • Dice rolls that everyone sees

Common Patterns

Score Counter

  • Create a number variable $score with default 0
  • On correct answer click: Set Variable, operation Add, value 1
  • Display the score using a text element with $score in the text

Quiz with Attempts

  • Create $attempts (number, default 0) and $passed (boolean, default false)
  • On each answer submission: Add 1 to $attempts
  • On correct answer: Set $passed to true
  • Add conditions to limit retries: only allow the quiz if $attempts < 3

Dice Roll

  • Create $diceRoll (number, default 1)
  • On dice button click: Set Variable, operation Random, min 1, max 6, mode Cycle
  • Display the result or use conditions to branch based on the roll

Toggle Visibility

  • Create $showHints (boolean, default false)
  • On "Show Hints" button click: Set Variable, operation Toggle
  • On hint elements: set visibleWhen to $showHints == true

Tips

  • Name variables descriptively: $quizScore is better than $s. You'll thank yourself when your Ripple has 20 variables.
  • Use Reset All sparingly: It resets everything. If you only need to reset a few variables, use individual Set actions instead.
  • Global + Random = shared dice: Set a random variable with global scope to create dice rolls, wheel spins, or random selections that everyone sees the same result for.

What's Next?