Skip to content

Conditions

Conditions are tests against game state that return true or false. They’re used in dialogue choices (REQUIRE), conditional branches (IF), triggered dialogues, and node visibility.

Multiple conditions on the same element use AND logic: all must pass.

Check if a flag is set to true.

REQUIRE hasFlag metBartender
ParameterTypeDescription
flagstringFlag key to check

Check if a flag is not set (false or undefined).

REQUIRE notFlag doorLocked
ParameterTypeDescription
flagstringFlag key to check

Check if an item is in the player’s inventory.

REQUIRE hasItem rusty_key
ParameterTypeDescription
itemIdstringItem ID to check for

Check if a variable equals a specific value.

REQUIRE variableEquals gold 100
REQUIRE variableEquals playerName "Aria"
ParameterTypeDescription
variablestringVariable key
valuenumber | stringValue to compare against

Check if a numeric variable is greater than a value (strict).

REQUIRE variableGreaterThan gold 4
ParameterTypeDescription
variablestringVariable key
valuenumberThreshold (exclusive)

Check if a numeric variable is less than a value (strict).

REQUIRE variableLessThan reputation 0
ParameterTypeDescription
variablestringVariable key
valuenumberThreshold (exclusive)

Check if the player is at a specific location.

REQUIRE atLocation tavern
ParameterTypeDescription
locationIdstringLocation ID

Check if a quest is at a specific stage.

REQUIRE questAtStage odd_jobs started
ParameterTypeDescription
questIdstringQuest ID
stageIdstringStage ID to check for

A quest that hasn’t been started has no stage, so questAtStage will return false.

Check if a character is at a specific location.

REQUIRE characterAt merchant market
ParameterTypeDescription
characterIdstringCharacter ID
locationIdstringLocation ID

Check if a character is in the player’s party.

REQUIRE characterInParty elisa
ParameterTypeDescription
characterIdstringCharacter ID

Check if relationship with a character is above a value (strict greater than).

REQUIRE relationshipAbove bartender 5
ParameterTypeDescription
characterIdstringCharacter ID
valuenumberMinimum value (exclusive)

Check if relationship with a character is below a value (strict less than).

REQUIRE relationshipBelow bartender 0
ParameterTypeDescription
characterIdstringCharacter ID
valuenumberMaximum value (exclusive)

Check if current time is within a range (24-hour format). Handles wrap-around (e.g., 20 to 6 means 8 PM to 6 AM).

REQUIRE timeIs 20 6
ParameterTypeDescription
startHournumberStart hour (0-23, inclusive)
endHournumberEnd hour (0-23, exclusive)

Check if an item is at a specific location.

REQUIRE itemAt sword armory
ParameterTypeDescription
itemIdstringItem ID
locationIdstringLocation ID

Roll a random integer between min and max (inclusive) and return true if the result is greater than or equal to threshold. The roll is not stored anywhere. Use the ROLL effect if you need the value.

REQUIRE roll 1 20 15
FieldTypeDescription
minnumberMinimum roll value (inclusive)
maxnumberMaximum roll value (inclusive)
thresholdnumberMinimum result needed to pass

Use ROLL effect first when you need to:

  • Show the player what they rolled (variable interpolation with {varName})
  • Branch on the result in multiple places
  • Reference the roll elsewhere in the scene

For a one-shot hidden check with no displayed result, the roll condition is simpler. See the Dice & Randomness guide.

On choices (shown only when condition passes):

Section titled “On choices (shown only when condition passes):”
CHOICE @buy_drink
REQUIRE variableGreaterThan gold 4
GOTO drink
END
IF questAtStage odd_jobs started
GOTO quest_update
END
TRIGGER tavern
REQUIRE notFlag seenIntro
CHOICE @secret_option
REQUIRE hasFlag metBartender
REQUIRE relationshipAbove bartender 5
REQUIRE hasItem old_coin
GOTO secret
END
import { evaluateCondition, evaluateConditions } from '@doodle-engine/core';
// Single condition
const passes = evaluateCondition(condition, gameState);
// Multiple conditions (AND logic)
const allPass = evaluateConditions(conditions, gameState);