Articles on: Discover the Creator

๐Ÿ”ข Set up numerical conditions

Example link:

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

Go to:

Let's open the example that is titled 03๐Ÿงฎ Numeric conditions this is a project that is pre-edited for the purpose of this tutorial.

Simply click on the cover picture to open the project.

2. Click on Main Menu / Variables

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 three ways to additionally change the value of a number variable.

1st method: Incrementing by selection

2nd method: Incrementing by connection

3rd method: Assignment + Expression

For mathematical operations other than addition and subtraction, the 3rd method will be necessary.

Find here the โž— Mathematical operations

**1st method: Incrementing by selection

Create an incremental block by clicking on Add Block in the top menu or by right-clicking the mouse.

To increment a variable by selecting it when

of a flow passage:

1) Create an increment block

2) Double-click on it to open its window.


3) Click Connect Variable

4) Choose the variable from the variables menu (or create a numeric variable)

5) Define the initial value of the numerical variable, i.e. its value when the flow starts on a Start block.

6) Click Select

7) Choose the number you want to add to the variable at the time the flow hits this block.

The view of the Assignment block changes to highlight the variable name, as well as the numeric addition made.

2nd method: Incrementing by connection

The Increment block is the combination between an assignment block and an expression block with an addition operation.

Open the block. You can change the value of the addition, by default it is set to 1. This means that if the History Thread passes through the Increment block, the corresponding Numbers variable will increase its value by 1.

You can close the Increment window.

Expand the variable point.

Select the variable Charisma.

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 directly in the graph how many points you increment the variable by. The title has no effect on the Flow or the variables.

3รจme mรฉthode: Assignation + 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. Unknowns are recognized automatically. Here, this is X.

The 'X' dot is empty. We need to tell the graph what variable 'X' is.ย 

Link the unknown 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.

7. Write a logical sentence

by opening the Alerte block.

In this example, we want to return to reality and escape the Matrix. We need at least 7 points of Charisma.

We need at least 7 points of Charisma to pass the test.

8. Create a Conditions block

by clicking on Add Block in the top bar or by right-clicking and clicking on other blocks. Select 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 expression 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 unknown dot.

A pop up menu appears. Select '_Charisma'_.

The _Charisma block_ appears.

Link the Alerte block to the Condition block.

9. Express the consequences

Use 2 Alerte 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 Alerte block and copy/paste it with Control+C and Control+V. All the content of the copied block is copied.

The 2 sentences can be:

You meet the condition. Well done. if True
You don't meet the condition, too bad! 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.

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 true/false conditions

Updated on: 20/10/2021

Was this article helpful?

Share your feedback


Thank you!