Effect: Change variable value

EffectNo. 9239

Synopsis

Choose the variable, who it affects and the operation: add, subtract, multiply, divide (whole-number division), modulo or set a minimum or maximum. Dividing by zero changes nothing. It does not create the variable: give it first with Effect: Give variable. In a stack, giving, changing and removing variables always run in that order, regardless of height.

Step by step

Add 5 points on every step

Boxes you need

  1. TriggerTrigger: Step on an object
  2. AddonAddon: Variable value in text
  3. EffectEffect: Change variable value
  4. EffectEffect: Give variable
  5. EffectEffect: Show message
  1. Place a walkable object A. Create a user variable “points”, with a value and duration while in the room; save.
  2. Stack “Walks on object”, “Give variable”, this effect, “Variable text” and “Show message”. Select A in the trigger.
  3. In “Give variable” choose Users, “points”, triggering user and initial value 0 without overwrite. In “Change value” choose the same variable and user, Add operation and fixed value 5.
  4. In “Variable text” use identifier “points”, Users, the “points” variable, triggering user, Numeric and Single. Set the message to “You have $(points) points”, for the triggering user.
  5. Save every box with delay 0. Step on A twice, stepping off between visits.

Result: The first step shows 5 points and the second shows 10.

Settings

Settings window of “Effect: Change variable value”
This box's window in the game (Spanish client).

Notes

  • Change value does not create the variable, which is why the stack also gives it. Giving, changing and preparing the text follow a fixed order independent of box height.
  • Effect: Change variable value doesn't create the variable: you need Effect: Give variable first.
  • Inside a stack the order is fixed: give → change → remove → $(…) is read → messages → signal. It doesn't depend on height.
  • Dividing by 0 and modulo 0 change nothing. Division is integer division.
  • “Set minimum” is a floor and “set maximum” is a ceiling.

Related

Used in these recipes