Creator Docs

Update Variable

Update Variable changes the value of a variable when a line plays. For example, you can add 1 to a number variable called Friendship. Or you can set a true or false variable called Has Key to true when the reader finds a key. One action can make many changes. Each change is called an operation.

What you need first

Create your variables on the Variables page first. This page uses Friendship, a Number variable, and Has Key, a Boolean variable.

Add the action to a line

  1. Open a scene in the scene editor, and select a line. See Scene Editor.

  2. Tap the + button.

    • Phone or tablet: The + button is in the toolbar at the bottom of the screen.
    • Desktop: The + button is under Presentation state, on the right.

    The Actions menu opens.

  3. Scroll down to the Logic group.

  4. Tap Update Variable. The Update Variable screen opens. It has no operations yet.

    The Actions menu on a phone, scrolled down to the Logic group. Update Variable is marked. The Actions menu on desktop, scrolled down to the Logic group. Update Variable is marked.

Add an operation

  1. Tap + Add Operation. The Edit Operation screen opens.

  2. Tap the Variable box, and choose a variable. For example, choose Friendship.

  3. Tap the Operation box, and choose an operation. For example, choose Increment by.

  4. In the Value box, type the number to use. It starts as 1.

    The Edit Operation screen on a phone. Variable shows Friendship, Operation shows Increment by, and Value shows 1. The Value box is marked. The Edit Operation screen on desktop. Variable shows Friendship, Operation shows Increment by, and Value shows 1. The Value box is marked.
  5. Tap Save Operation. The operation shows in the list, for example Friendship: Increment by 1.

  6. To add another operation, repeat steps 1 to 5. For example, choose Has Key and Set to. Then choose True in the Value box.

  7. Tap Submit to save the action on the line.

    The Update Variable screen on a phone with two operations: Friendship Increment by 1, and Has Key Set to True. The Submit button is marked. The Update Variable screen on desktop with two operations: Friendship Increment by 1, and Has Key Set to True. The Submit button is marked.

Operations

The operations you can choose depend on the type of the variable.

Variable type Operation What it does
Number Set to Replaces the value with your number.
Number Increment by Adds your number.
Number Decrement by Subtracts your number.
Number Multiply by Multiplies the value by your number.
Number Divide by Divides the value by your number. Decimal Places sets how many digits to keep after the point. It starts at 2.
Boolean Set to Sets the value to True or False.
Boolean Toggle Switches True to False, or False to True. It has no value box.
String Set to Replaces the text. For an enum variable, you choose a value from a list.

Change an operation

  1. Tap the line with the action.
  2. Tap the + button. Then tap Update Variable. The screen shows the operations of this line.
  3. Tap the operation.
  4. Change Variable, Operation, or Value.
  5. Tap Save Operation.
  6. Tap Submit.

Delete an operation

  1. Open the Update Variable screen of the line. Do steps 1 and 2 of "Change an operation".

  2. Open the menu of the operation.

    • Phone or tablet: Long press (touch and hold) the operation.
    • Desktop: Right-click the operation.
  3. Tap Delete.

    The Update Variable screen on a phone after a long press on the first operation. A menu with one item, Delete, is open. Delete is marked. The Update Variable screen on desktop after a right-click on the first operation. A menu with one item, Delete, is open. Delete is marked.
  4. Tap Submit.

Other places that run Update Variable

Update Variable also runs when the reader does something. It works the same way. Choose Update Variable in the Logic group.

Place When it runs
Controls The reader presses or releases a key. Add it under Keydown or Keyup of a control.
Layouts The reader clicks an element. Add it in the Actions of the element in the layout editor.
Choices The reader picks a choice. Add it in Update Variables on the Edit Choice screen.
Conditional The condition of a branch matches. Add it to the actions of the branch.

Good to know

  • Computed variables are not in the Variable list. They work out their value from other variables, so you cannot update them.
  • When you choose another variable, Operation goes back to Set to.

Next steps