Skip to content

★ Conditions

Sample game

Comparison operators

Operator Description
is is equal?
is not is different from?
> is bigger?
>= is bigger or equal?
< is smaller?
<= is smaller or equal?

See more in documentation:



The if-elseif-else instructions

(if: )

Example 1
Depending on whether the gate is closed or opened (true/false), you can see a hidden message. The value of the $gate_closed variable may be changed in any slip or in any particular location in a particular fragment of the story (it does not have to change its value at the top of the slip – it can be done between the paragraphs of the text).

(set: $gate_closed to true)
You try to open the gate... (if: $gate_closed is true)[- unfortunately it is closed! First, you need to get the key.]

Result 1

Example if - result 1



Example 2
If you use a lot of variables, IF instructions, etc. to increase the clarity of the code (a possibility of using whitespace characters, such as ENTER), use { } characters and code indentation. It will allow you to avoid awkward and unexpected empty space on your slips.

(set: $tip to  1)

You try to open the gate... unfortunately, it is closed!

{     (if: $tip is 1)[maybe I should look for the key in my pocket?]     (if: $tip is 2)[maybe I should check under the flowerpot?]     (if: $tip is 3)[it seems you need to find another way!] }

Result 2

Example if - result 2

See more in documentation



(if: )(else: )

Example 3

(set: $key_found to false)

You try to open the gate...

{     (if: $key_found is true)[you open the gate with the key you have found and you enter the courtyard.]     (else:)[- unfortunately, it is closed! First, you need to get the key.] }

You can save the IF instruction in its shorter version (if: $key_found)[...] because the $key_found variable shall take true or false - it does not have to be additionally compared using the is operator.

Result 3

Example if - result 3

See more in documentation



(if: )(else-if: )(else: )

Example 4

(set: $points to 10)

SUMMING UP: you have got $points points.

{     (if: $points >= 15)[Well done!]     (else-if: $points is 0)[Bad luck!]     (else:)[Not bad! It will be even better next time.] }

Result 4

Example if - result 4

See more in documentation



If the gate is closed (true), you will see a text with a link to the "key" slip, otherwise (false) you will see a text with a link to the "courtyard" slip. You can fully decide which links will be visible for players and which links will stay hidden.

Example

(set: $gate_closed to false)
(set: $congratulations to "You’ve made it!")

You try to open the gate...

{     (if: $gate_closed is true)[First, you need to get the [[key]].]     (else:)[$congratulations You can go to the [[courtyard]].] }

An editor view

The IF instruction, links and variables - an editor view

Result

The IF instruction, links and variables - result



The IF and (display: ) instruction

The (display: ) macro allows you to display the content of a particular (already existing) slip on another slip. You can also see another example of applying that macro in the tutorial part referring to randomness.

Example

(set: $action to 2)

You enter the courtyard.

{     (if: $action is 1)[(display: "action-1")]     (else-if: $action is 2)[(display: "action-2")]     (else-if: $action is 3)[(display: "action-3")]     (else:)[However, there is nobody there.] }

An editor view

The IF and display instruction - an editor view

Result

The IF and display instruction - result



Logical operators

Operator Description
and logical conjunction
or logical disjunction
not logical negation

Logical conjunction and

The result of the and (logical conjunction) operation is the True value if and only if the value of both arguments is True.

Argument 1 Argument 2 Result
True True True
True False False
False True False
False False False

Logical disjunction or

The result of the or (logical disjunction) operation is the True if the value of at least one argument is True. The False value occurs if and only if the value of both arguments is False.

Argument 1 Argument 2 Result
True True True
True False True
False True True
False False False

Logical negation not

The result of the not operation is the opposite value of the argument.

Argument Result
True False
False True


Example

(set: $night to false)
(set: $flashlight_on to false)

It is (if: $night)[night](else:)[day]. There is an (if: $flashlight_on)[on](else:)[off] flashlight.

{     (if: $night and $flashlight_on)[You notice some strange symbols on the wall. It might be some kind of a password...]     (else-if: not $night and $flashlight_on)[Turning on your flashlight is not a good idea.]     (else-if: $night and not $flashlight_on)[It would be a good idea to turn on your flashlight. It’s very dark in here.]     (else:)[You should wait until the evening and turn on your flashlight to see whether there are any tips hidden in here.] }

Result

Logical operators - result



More information