Conditions are lead by variables in a graph. A variable is an indicator which can see its value vary.
Here is the value that can have each type of variable:
Boolean: True or False
Number: 1, 2, 3...
Text: chain of characters
Here we will look at how to create advanced variables, and more precisely, variables that work with numbers.
1. To Start in Celestory
Let's open the example that is titled 'Bot (en)' this is a project that is pre-edited for the purpose of this tutorial.
Simply click on the cover picture to open the project.
Let's delete part of the graph after the first choice to test the Boolean variable.
2. Click on Main Menu / Variables
To remove a variable go to the Main Menu, in the far left corner with the name of the project file on. Scroll down to Variables click once on Variables to open up a pop up window then click on Remove
Click on Add variable.
3. Create a Number variable
Click on Add variable. Select the variable type Number and click on Add variable.
Let's label it 'Charisma'.
Let's imagine that the user can have a Charisma value between 0 and 10. Here we will select 5 as the initial value, which is the value when the storyline begins at the 'Start' block.
There are two ways to change the value of a variable "number"
Method a) Add an Assign block + Expression block with a mathematical operation (ex: "X + 5")
Method b) Add an Increment / Decrement block
For other mathematical operations the Expression block will be needed.
Method a) Assign block + Expression
4. Create an Assign block
This has the feature to change the value of a variable when the Storyline passes through this block. Create also a Dialogue block after the choice.
Right click on an empty space of the Graph and click on Add block
Click on the Assign block to add it to the graph after.
Click on the variable dot and drag the mouse to an empty space of the graph.
A pop up menu will show the options to select the variable you want to change the value of. In this case select 'Charisma'.
Now the variable dot is linked. The value dot is also linked.
Double click on the Assign block here it shows that the value dot is set up by default to '0'.
It means that if the Storyline goes through the Assign block the variable 'Charisma' will always be equal to 0 irrelevent to it's previous value.
5. Change the value of the variable
There are 2 ways to change a value of a variable:
- Arbitrary; without consideration of its previous value
- Relatively; keeping its previous value.
Like in the movie Matrix, the user will face a choice:
Take the Red 🔴 or the Blue pill 🔵
Let's say that after taking the Red pill, your Charisma increases by 2 points.
Click the dot next to 'value' and drag the mouse to an empty space of the Graph. Then select 'Expression'.
The Expression block pops up.
Double click on the Expression block. A pop up Expression box appears.
6. Write your mathematical expression
In our example, we want to increases the Charisma by 2 points, so we want the previous value of the variable to gain 2 points.
Therefore we write the expression "X + 2".
Close the Expression pop up box, notice the unknown appearing on the Expression block. Unknows are recognized automatically. Here, this is X.
The 'X' dot is empty. We need to tell the graph what variable 'X' is.
Link the unkown dot to the Charisma variable. (We could have recreated another variable block. Their numbers don't influence the Storyline).
Now link the 'Red choice' to the Assign block, the Assign block and the 'Blue' choice to the next Dialogue block.
As the Storyline link after the Blue choice can be visually confusing, let's reorganize it. Double-click on 2 different parts of the link to create contorsion dots.
Hold click and drag the dots under the Expression block.
Method b) An Increment / Decrement block
Create an Increment block by right clicking andwhere on the graph select 'Add block' and choose Increment.
An Increment block is the combinaison between an Assign block and an Expression block with an addition operation.
Open the Increment block. You can change the value of the addition, by default it is set to 1. That means if the Storyline goes through the Increment block, the related Number variable will increase value by 1.
You can close the Increment window.
Extend the variable dot.
Select the Charisma variable.
The variable is now linked to the Increment block.
Then complete the links.
You can also change the title of the Increment block to see it directly on the graph how many times you change the the variables. The title of the block doesn't have any effect on the story or the variables.
7. Write a logical statement
Open the Dialogue block.
In this example, we want to go back to reality and escape the Matrix. We need at least 7 points of Charisma.
In the dialogue block let's add some text for our character Alex.
Example: 'Alex: You need at least 7 points of Charisma to escape the Matrix.'
8. Create a Condition block
Add a Condition block. Right click, select Add Block and choose the Condition block.
The Condition block appears.
Click and drag the dot 'condition' on the condition block to an empty space of the graph.
A pop up menu appears. Select Expression.
The Expression block appears.
Double click on it the expresion block.
We want to express logically the sentence of Alex. He will let the user pass if the Charisma is at least equal to 7 points.
So the mathematical expression to write is: "X >= 7".
When closing the Expression pop up window, an unknown is appears on the Expression block.
Let's tell the graph at what variable X is related to. Hold click and drag your mouse to an empty space of the graph to extend the unkown dot.
A pop up menu appears. Select 'Charisma'.
The Charisma block appears.
Link the Dialogue block to the Condition block.
9. Express the consequences
Use 2 Dialogue blocks with Alex's expressions.
You can create the blocks with 'Add block' by Right clicking anyway on the graph.
You can also click on the Dialogue block and copy/paste it with Control+C and Control+V. All the content of the copied block is copied.
The 2 sentences of Alex can be:
- Alex: Get out of here whilst you still can if True
- Alex: You don't have what it takes to escape if False
The expression X >= 7 can or cannot be verified. In this case the variable is invisible as Alex does not tell you exactly what is wrong (the expression which is or is not verified).
10. Test-play the graph
Click on 'Play' to preview your scenario. Click on the 'Play test' window to continue the preview. Click on the 'Variables' tab inside the 'Debug' window to see the Charisma changing value.
By choosing the 'Red pill' the Charisma now has a value of 7. As initially it was at 5 and then gained 2 points.
As the Storyline goes through the Condition block, the condition is verified and the Storyline is redirected to True.
Alex then tells the user he can escape the Matrix.
Congrats, you gave your scenario an advanced intelligence! You are now ready to create a deep simulation where every link in the Storyline can change by an infinity of variables.
To learn how to master Boolean type variables, go to ☑️ Set up conditions
To understand all the elements in the interface, go see the Tool Elements.