LiminaliaLiminalia
How-to: Run a single line on a condition

Run a single line on a condition

Open in Claude (new tab)
On this page

To run just one line on a condition, you don’t have to wrap it in @if to @end. Write if=(expression) at the end of that command line instead. If the expression is false, the line is skipped and the game goes on to the next line. All the lines on this page are written in the code view.

The examples on this page use the English sample story, “Waiting for Stars” (choose “A sample story” and English in New Project, or run lim new --lang en; the characters are Akari and Sou).

Write a condition at the end of a line

  1. In the code view, put the cursor at the end of the command line you want to add a condition to.
  2. Type a space, then if=(expression).
@chara Akari smile if=(game.trust >= 2)

This one line behaves the same as these three lines.

@if game.trust >= 2
@chara Akari smile
@end

Check and the flowchart also treat it the same as wrapping it in @if. The expression is written the same way as in @if, and you can use functions as well as variables (Branch on visits and earlier choices).

Always wrap the expression in ( ). If you write it without them, as in if=game.night, you get an error in Check, with if=(game.night) as the suggested fix.

Lines you can write it on

Besides commands for effects, you can write it on variable lines (@set, @let), jumps (@jump), calls (@call), returns (@return), and macro and custom command lines.

@bg hill_night.webp if=(game.night)
@set game.met = true if=(!game.met)
@se chime.wav if=(visits("#room") == 1)
@call #rules if=(!read("#rules"))
@jump #angry if=(game.trust < 0)
@return if=(game.met)
  • Change the background only at night.
  • If the player hasn’t met the character yet, record in a variable that they have.
  • Play a sound effect only the first time the player enters the scene.
  • If the player hasn’t read the explanation scene yet, call it so they read it.
  • If trust has dropped, jump to another scene. If the condition is false, the game goes on to the next line, so lines after @jump can still be reached.
  • Partway through a called scene, return only when the condition is met.

The name of a @let with if= can be used in later lines too. If the condition is false, it stays without a value.

Lines you can’t write it on

  • Dialogue and narration lines. Even if you write it at the end, it’s shown as part of the text. To put a condition on dialogue or narration, wrap it in @if.
  • Commands that open blocks (@if, @while, @for, @choice, @define and so on), @end, @with, and {@…} in text. Writing it there is an error in Check.
  • To show choices on a condition, write if= on the choice line, not on the @choice line (Show or lock choices with conditions).

If you’re coming from TyranoScript, this is the equivalent of cond= on tags.

In code

# room
@bg hill_night.webp if=(game.night)
@chara Akari smile if=(game.trust >= 2)
@set game.met = true if=(!game.met)
@se chime.wav if=(visits("#room") == 1)
Akari "Good evening."
@call #rules if=(!read("#rules"))
@jump #angry if=(game.trust < 0)
Akari "The sky's really clear tonight."
@jump #night

# angry
Akari "...Please just go home for today."
@title-screen

# rules
Sou "Don't touch the telescope without asking."
@return if=(game.met)
Sou "And write your name down for me."
@return

# night
The sky was full of stars.

Commands used on this page

@chara@bg@se@title-screen