Conditions
A condition is a check. Lines inside it happen only when the check is true: only if the player has the fish, only the first time, only if courage is 2 or more.
The If menu
Type > if and a space, click Insert If statement, or press ⌥ ⇧ /. The If menu opens.
- Choose what to check.
- Fill in the rest, like the variable and the number.
- Add more cases with + Add another case (Else if), or a case for everything else with Otherwise (Else).
- Click Add.
The Yarn this writes shows the lines Tsumugi will write, before it writes them.
What you can check
| Check | For example |
|---|---|
| A variable | courage is at least 2 |
| Has an item | has more than 10 Onigiri |
| Has been to a node | visited Harbour more than 2 times |
| Only the first time | the first time the player gets here |
| What the player typed | the typed answer is “yes” |
| Has unlocked | has unlocked Brave |
Some checks show only when your game has what they need: items, typed answers or unlocks.
- + And another check adds a check to the same case. Pick and (both must be true) or or (one is enough).
- Need a variable you don’t have yet? Pick New variable… in the list.
- Typed answers match with small or capital letters alike.
Counting items
To check how many of an item the player has, your game needs a small counting function. If it has none, Tsumugi offers Add a count function. When Tsumugi found where your game keeps its items, the function it writes works straight away. If not, a programmer fills it in.
In the file
Lines that happen only sometimes sit between <<if>> and <<endif>>:
<<if $courage >= 2>>
Ayumi: You're braver than you look.
<<elseif visited("Harbour")>>
Ayumi: Back from the harbour?
<<else>>
Ayumi: Be careful out there.
<<endif>>
Warning
Every <<if>> needs its <<endif>>. Without it the game stops, so Tsumugi shows the line as broken (red).
A check at the end of an option belongs to that one option, and needs no <<endif>>. See Options, jumps and hops.
How the Story Writer shows it
An If block shows its cases side by side, as columns. Each column is headed by its check, in plain words, like courage ≥ 2 or Else. The story goes on under the columns.
- Click a heading to change its check.
- + (top right) adds a case.
- To write in one case alone, point at the block and click the enlarge button on its heading. Esc puts everything side by side again.
- On an empty line at the end of a column, Enter takes you out under the block, past the
<<endif>>. - With more columns than fit, arrows at the ends show the rest.
Inside an If, the event menu also has Else if, Else and End if.
In the preview
The preview takes the branch each check picks, using the variables, items and visits from your play so far. See The preview.
Note
A check that calls your game’s own code can’t run in the preview, so it counts as true. Try those in GameMaker.