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 triggered interludes.
Multiple conditions on the same element use AND logic: all must pass.
hasFlag
Section titled “hasFlag”Check if a flag is set to true.
REQUIRE hasFlag metBartender| Parameter | Type | Description |
|---|---|---|
flag |
string |
Flag key to check |
notFlag
Section titled “notFlag”Check if a flag is not set (false or undefined).
REQUIRE notFlag doorLocked| Parameter | Type | Description |
|---|---|---|
flag |
string |
Flag key to check |
hasItem
Section titled “hasItem”Check if an item is in the player’s inventory.
REQUIRE hasItem rusty_key| Parameter | Type | Description |
|---|---|---|
itemId |
string |
Item ID to check for |
variableEquals
Section titled “variableEquals”Check if a variable equals a specific value.
REQUIRE variableEquals gold 100REQUIRE variableEquals playerName Aria| Parameter | Type | Description |
|---|---|---|
variable |
string |
Variable key |
value |
number | string |
Value to compare against |
variableGreaterThan
Section titled “variableGreaterThan”Check if a numeric variable is greater than a value (strict).
REQUIRE variableGreaterThan gold 4| Parameter | Type | Description |
|---|---|---|
variable |
string |
Variable key |
value |
number |
Threshold (exclusive) |
variableLessThan
Section titled “variableLessThan”Check if a numeric variable is less than a value (strict).
REQUIRE variableLessThan reputation 0| Parameter | Type | Description |
|---|---|---|
variable |
string |
Variable key |
value |
number |
Threshold (exclusive) |
characterStatEquals
Section titled “characterStatEquals”Check whether a character stat exactly equals a number or string. Use the
reserved character ID player for the player character.
REQUIRE characterStatEquals player class @class.rangerREQUIRE characterStatEquals elisa level 5| Parameter | Type | Description |
|---|---|---|
characterId |
string |
Character ID or player |
stat |
string |
Stable stat key |
value |
number | string |
Value to compare against |
Numbers only equal numbers and strings only equal strings. The engine does not convert between them.
characterStatGreaterThan
Section titled “characterStatGreaterThan”Check whether a numeric character stat is strictly greater than a number.
REQUIRE characterStatGreaterThan player strength 16.1| Parameter | Type | Description |
|---|---|---|
characterId |
string |
Character ID or player |
stat |
string |
Stable stat key |
value |
number |
Threshold (exclusive) |
This condition returns false when the stat is missing or is a string.
characterStatLessThan
Section titled “characterStatLessThan”Check whether a numeric character stat is strictly less than a number.
REQUIRE characterStatLessThan elisa strength 18| Parameter | Type | Description |
|---|---|---|
characterId |
string |
Character ID or player |
stat |
string |
Stable stat key |
value |
number |
Threshold (exclusive) |
This condition returns false when the stat is missing or is a string.
atLocation
Section titled “atLocation”Check if the player is at a specific location.
REQUIRE atLocation tavern| Parameter | Type | Description |
|---|---|---|
locationId |
string |
Location ID |
questAtStage
Section titled “questAtStage”Check if a quest is at a specific stage.
REQUIRE questAtStage odd_jobs started| Parameter | Type | Description |
|---|---|---|
questId |
string |
Quest ID |
stageId |
string |
Stage ID to check for |
A quest that hasn’t been started has no stage, so questAtStage will return false.
Use questAtStage for a specific progression step. Use questStatus for whether a quest has started, is underway, or has finished.
questStatus
Section titled “questStatus”Check whether a quest has not started, is active, or is complete.
REQUIRE questStatus odd_jobs active| Parameter | Type | Description |
|---|---|---|
questId |
string |
Quest ID |
status |
not_started | active | complete |
Status to check |
characterAt
Section titled “characterAt”Check if a character is at a specific location.
REQUIRE characterAt merchant market| Parameter | Type | Description |
|---|---|---|
characterId |
string |
Character ID |
locationId |
string |
Location ID |
characterInParty
Section titled “characterInParty”Check if a character is in the player’s party.
REQUIRE characterInParty elisa| Parameter | Type | Description |
|---|---|---|
characterId |
string |
Character ID |
relationshipAbove
Section titled “relationshipAbove”Check if relationship with a character is above a value (strict greater than).
REQUIRE relationshipAbove bartender 5| Parameter | Type | Description |
|---|---|---|
characterId |
string |
Character ID |
value |
number |
Minimum value (exclusive) |
relationshipBelow
Section titled “relationshipBelow”Check if relationship with a character is below a value (strict less than).
REQUIRE relationshipBelow bartender 0| Parameter | Type | Description |
|---|---|---|
characterId |
string |
Character ID |
value |
number |
Maximum value (exclusive) |
timeIs
Section titled “timeIs”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| Parameter | Type | Description |
|---|---|---|
startHour |
number |
Start hour (0-23, inclusive) |
endHour |
number |
End hour (0-23, exclusive) |
itemAt
Section titled “itemAt”Check whether an item is at a specific location. REMOVE item clears the
item’s location, so itemAt returns false for every location, including
inventory.
REQUIRE itemAt sword armory| Parameter | Type | Description |
|---|---|---|
itemId |
string |
Item ID |
locationId |
string |
Location ID |
Roll a random whole number between min and max (inclusive) and return true if the result is greater than or equal to threshold. This condition returns only true or false. The ROLL effect stores the result in a variable.
IF roll 1 20 15 GOTO lucky_findEND| Field | Type | Description |
|---|---|---|
min |
number |
Minimum roll value (inclusive) |
max |
number |
Maximum roll value (inclusive) |
threshold |
number |
Minimum result needed to pass |
min and max must be whole numbers, and min cannot be greater than max.
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
Use roll for a hidden check in an IF block or triggered content. To roll when the player picks a choice, route that choice to a node that uses ROLL and IF. See the Dice & Randomness guide.
Using Conditions in Dialogue
Section titled “Using Conditions in Dialogue”On choices (shown only when condition passes):
Section titled “On choices (shown only when condition passes):”CHOICE @buy_drink REQUIRE variableGreaterThan gold 4 GOTO drinkENDOn conditional branches:
Section titled “On conditional branches:”IF questAtStage odd_jobs started SET flag sawQuestUpdate GOTO quest_updateENDEffects inside an IF block run only if that IF condition passes. If multiple IF blocks pass, only the first passing block runs.
On triggered dialogues (top-level):
Section titled “On triggered dialogues (top-level):”TRIGGER tavernREQUIRE notFlag seenIntroMultiple conditions (AND logic):
Section titled “Multiple conditions (AND logic):”CHOICE @secret_option REQUIRE hasFlag metBartender REQUIRE relationshipAbove bartender 5 REQUIRE hasItem old_coin GOTO secretENDTypeScript API
Section titled “TypeScript API”import { evaluateCondition, evaluateConditions } from '@doodle-engine/core';
// Single conditionconst passes = evaluateCondition(condition, gameState);
// Multiple conditions (AND logic)const allPass = evaluateConditions(conditions, gameState);