Conditional blocks are powerful tools that let you show different content to readers based on specific conditions. Think of them as creating branching paths in your story that readers might or might not see, depending on their previous choices or actions.
The simplest form of a conditional is the "if" block. It shows its contents only when its condition is true.
In this example, the text about being wounded only appears if the condition isHeroWounded
is true. If it's false, readers won't see this text at all.
isHeroWounded
is a variable - a special container that stores values (like true/false, numbers, or text) that you can set and check in your story. Don't worry too much about variables right now - we'll cover them in depth in the next guide. For now, just know that they're how we keep track of things in our story!Sometimes you want to show one thing when a condition is true, and something different when it's false. That's where the "if-else" block comes in:
Conditions aren't limited to simple true/false checks. You can compare values using these operators:
=
equals>
greater than<
less thanHere's how you might use them:
Sometimes you need to check multiple things at once. You can combine conditions using:
and
: both conditions must be trueor
: at least one condition must be truenot
: reverses a conditionHere are some examples:
Keep it Natural: Use conditionals to make your story feel more responsive to the reader's choices. Don't overuse them just because you can.
Think Branch Points: Conditionals are perfect for creating different story paths based on previous choices or acquired items.
Layer Them: You can put conditional blocks inside other conditional blocks to create complex branching scenarios (but it is recommended to avoid complex branching when possible, as it can quickly get confusing):
Now that you understand how to create branching content with conditionals, you might be wondering: "How do I actually set and track all these conditions?" That's where variables come in, which we'll cover in the next guide!