If the concept of a variable is totally abstract for you, I advise you to consult the
following article before continuing: All about variables.
In this article are presented the following stories:
Assign
Decrease
Increment
Calculation
Random
Assign Story
The Assign story allows us to create and modify a variable.
Let's start by creating an Assign story:
You have 2 choices:
Choose an existing variable from the drop-down list to edit it.
Create a variable by inserting the name of the new variable.
You just have to insert the value to assign to the variable.
When the bot executes this story, it will be completely invisible to the user.
It is also possible to give the variable the value of another existing variable by
clicking on the {...}
We created a variable whose name is "myvariable" and for value "5":
Let's check that the operation works by asking the bot to display the value of the
variable myvariable.
Let's run the bot to see the result:
It is confirmed, our variable "myvariable" has the value 5. We can now manipulate it
from any sequence of our bot.
Now let's manipulate this variable with the stories Increment and Decrement.
💡 To reset an already filled variable to 0, simply put the name of the variable and
set the value to empty.
Increasing and Decrementing Stories
Let's create a new sequence with an Increment story.
We will choose the variable "myvariable" and put in the value field the value 2.
When the bot executes this story, it will add 2 to the value of the variable
"myvariable"
Let's check the result with the help of a story Text:
Let's run the bot to see the result:
The value of the variable has changed, it is now 7 (5 + 2).
The logic of the Decrement story is the same except that instead of adding a value,
we subtract.
Calculation Story
This story also allows you to manipulate a variable, but unlike Increment and
Decrement, you can do a calculation from two values.
Let's create a new variable named "six" and for value "6".
Then let's create a Calculation story to store in the variable "myVariable" the addition
of 10 and the value of the variable "six"
Let's look at what the bot shows us:
The variable "myVariable" has highlighted the result of the operation.
There are several operations available:
The addition
The subtraction
The multiplication
The division
Random Story
This story will allow us to give a variable a random value between a minimum value
included and a maximum value included.
Here is an example of use:
Each time the bot executes this story, the variable "variable" will have a random
value in 1 and 10: