Check...Else

Else lines make either-or checks easier to understand and write. In situations where you would normally use two check lines as counterparts, else lines can replace the second one.

In other words, else lines mark the alternative case if a check line resolves to false.

If checks in general are new to you, you may want to read the article about check lines before dealing with else lines.

Add an else line to a check

Else lines complement check lines. Create them by putting an :ELSE: tag on a new line. That line should be somewhere below a check line.

:CARD: weather

:SWITCH: sunnyDay

:CHECK: sunnyDay
It's such nice weather. You can eat at one of those cute tables Alfonso has put in front of his shop.

:ELSE:
"Heck, it's pouring," you exclaim as you stumble into Alfonso's shop.

:LINK: Fast forward to next day | weather

A check line determines whether the line below it will be processed:

  1. If the check resolves to yes (true), the line below will get processed.
  2. If the check resolves to no (false), it will not.

An else line marks the line that gets processed if the check resolves to false. Consequently, if the check resolves to true, the else line and the line it marks are ignored.

The example above is very similar to the first one in the article about check lines. The else line achieves the same thing as the second check in that example, but without writing a second statement.

Else lines do not work on their own. If you write an else line without writing a check line somewhere above it, the else line will be ignored.

Workflow tip: Instead of the :ELSE: tag you can also use :OTHERWISE:. Both achieve the exact same thing. Use the tag that makes more sense to you.

Manipulate groups of lines

Check lines can manipulate groups of lines. The same is possible with else lines. Just write the number of lines after the :ELSE: tag.

:CARD: cought a cold
Last week when it was raining cats and dogs you caught a cold.

:CHECK: $randomItem(good,bad) == good
Francesca hands you a tissue as you come in – just in time.
"You definitely need my new creation: the peppermint pizza. You'll feel better in no time."

:ELSE: 2
As you come in you sneeze loudly right into the shop. Everybody is looking at you. A baby starts to cry.
"Now see what you've done", Francesca says as she hurries over with the mop.

Because of the 2 after the :ELSE: tag the else line affects both lines below it.

A check line affects all lines until its else line. Like in line 3 above, if a check line is followed by an else line, the check line does not need a line parameter. However, an else line always needs a line parameter to affect more than one line.

Practice tip: If you're not sure what $randomItem(good,bad) does, read up on generated values.

Nested check...else

Else lines make it a little easier to nest checks into one another, i.e. to create a hierarchy of checks.

:CARD: how are things going

:CHECK: sneezedWithoutSelfControl
Francesca hasn't stopped glaring at you. You feel bad.

:ELSE: 4
:CHECK: somethingOddOnYourPizza
You wonder why your pizza tastes odd. Must be Francesca's new creation.
:ELSE:
Everything is just super. Have a nice day.

In this example, the first check fails. Because of that the second check-else group gets processed. That means the second check is nested into the first.

Only nest checks below the else line. Nesting checks above it changes the check-else pairing, resulting in a mess of galactic proportions.

Practice tip: Experiment with the not-operator !. Put it in front of the switch names on the check lines. Test different combinations and try to understand the result.

Practice tip (for adventurers): Try to make the example above work the same way with only check lines and no else lines. Can you do it?