Understanding Conditional Blocks

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 If Block

The simplest form of a conditional is the "if" block. It shows its contents only when its condition is true.

Try it out!

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.

Adding an Else Option

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:

Try it out!

Making Comparisons

Conditions aren't limited to simple true/false checks. You can compare values using these operators:

  • = equals
  • > greater than
  • < less than

Here's how you might use them:

Try it out!

Combining Conditions

Sometimes you need to check multiple things at once. You can combine conditions using:

  • and: both conditions must be true
  • or: at least one condition must be true
  • not: reverses a condition

Here are some examples:

Try it out!

Tips for Using Conditionals

  1. 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.

  2. Think Branch Points: Conditionals are perfect for creating different story paths based on previous choices or acquired items.

  3. 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):

Try it out!

What's Next?

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!