Getting Started with Variables and Conditions

Learn How to Manage Variables and Conditions on Aryel!

Aryel
Written by AryelLast update 1 month ago

This article will dive into the world of variables to understand how they function. Let's begin!

Variables are a powerful tool to simplify many interactions on the platform, allowing users to condense several steps into a few.

To get started, you need to introduce variables within the experience. Once done, you can reference or modify them in any scene.

To create a variable, simply click the "Variables" button located at the bottom left corner of the builder.

From there, you can click on "Let’s start now" to initiate the creation of your first variable.

In this area, you'll find the following options:

  • Name: Represents the variable's name. Always enclose the name in curly braces. To reference it within scenes, always use the variable name surrounded by its associated curly braces.

  • Type: Specifies the kind of variable you wish to create. Variables can be of three types:

    • Text: This variable can hold any keyboard character.

    • Numeric: This variable can contain numbers.

    • Boolean: This variable can hold either "true" or "false" values.

  • Starting Value: Here, you can set the variable's initial state. Depending on the type selected, you can choose words or character strings for 'text', a starting number for 'numeric', or a "true" or "false" state for 'boolean'.

  • Actions: Under this section, there are two buttons:

    • Accept as queryParam: By activating this, the variable can be inserted into the URL string. Read this article to learn more.

    • Delete: This allows you to delete the variable.

  • Create variable: This enables the creation of a new variable.

Note: Always remember to save after creating or modifying variables!

Once the variables are created, you can interact with them through asset interactions within a scene. After choosing a "Starting event", various "Result of interaction" types can be selected.

Interactions involving variables include:

  • Set Variable: This allows you to set a previously created variable to a different value.

Edit Variable: Modify an existing variable through various operations.

  • Text variable: From the dropdown menu, you can select the following options:

    • Add: Appends characters entered in the field to the right to the existing variable value.

    • Replace: Replaces the existing variable values with those entered in the field to the right.

  • Numeric variable: You can perform basic arithmetic operations like addition, subtraction, multiplication, or division on the numeric variable, altering its value accordingly. The value entered in the field to the right will thus be added to, subtracted from, multiplied by, or divided by the initial variable value.

  • Boolean variables cannot be acted upon in "Edit Variable".

  • Reset Variable: Resets the variable to its initial value.

Another critical aspect of maximizing variable functionality is conditions. These ensure interactions occur if certain criteria are met or unmet. Conditions can be used in every type of interaction.

To add a condition, first, introduce an interaction. Next, click on “Add condition” at the bottom right of the interaction panel.

Three fields will then appear:

  • Variable: From the dropdown menu, select the variable to apply a condition to.

  • Operator: This dropdown menu lets you select possible operators like greater than, less than, or equal to. The available operators change based on the chosen variable.

  • Value: Enter the reference value for the selected operator.

For better understanding, the condition string can be read as:

"if {variable} is {operator} compared to {value}, then {interaction}"

Furthermore, multiple conditions can be added to a single interaction. You can decide if the interaction activates when all conditions are met or just some, based on selections made when adding more than the required conditions.

That's it! You're now ready to venture and create with Aryel's variables!

Did this answer your question?