ssod

Conditional Tag Syntax: <if ...>

Displays or hides a block of content depending on player state. Conditions can be combined using and, or, and not, and grouped with parentheses. This system supports recursive expressions, stat comparisons, and predicate-based checks.

Syntax Examples

<if EXP eq 5> ... <else> ... <endif>
<if luck gt dice> ... <endif>
<if flag sword_found> ... <endif>
<if !item "healing potion"> ... <endif>
<if (exp gt 10 and flag quest_started)> ... <endif>
<if not mounted> ... <endif>
<if flag has_sword eq "yes"> ... <endif>
<if flag dungeon_code eq "1234"> ... <endif>

๐Ÿ”น Comparison Expressions

Use these to compare numeric game state values:

Examples:

<if luck gt 3> You are lucky. <endif>
<if mana lt dice> Your spell fizzles. <endif>

๐Ÿ”น Flag Checks

Check for flags previously set via <set>, <setglobal>, or other mechanisms.

Example:

<if flag has_ring> The ring glows. <else> It's dark. <endif>
<if flag dungeon_code eq "1234"> The door unlocks. <endif>

๐Ÿ”น Item and Inventory Checks

Check whether the player has certain items, spells, or herbs.

Example:

<if !item "healing potion"> You should get one. <endif>

๐Ÿ”น Quantity Checks

Check whether the player has at least a certain number of a specific item.

Example:

<if has 2 rations> You eat a ration. <endif>

๐Ÿ”น Race and Profession Checks

Determine the playerโ€™s race or profession, matching against supported values.

Example:

<if race darkelf> You sense the Severance. <endif>
<if prof wizard> You read the spellbook. <endif>

๐Ÿ”น Unary Predicates (No Arguments)

These check singular player states:

Syntax:

<if premium> Welcome back, thanks for subscribing! <endif>
<if not water> You are dehydrated. <endif>

๐Ÿ”น Logical Operators

Combine multiple conditions using:

Example:

<if (flag foo and not item "key")> You are locked in. <endif>
<if (luck gt 3 or premium)> You find a shortcut. <endif>

๐Ÿ”น Else Support

The <else> tag may appear once between <if> and <endif>.

Example:

<if flag knows_truth> You nod. <else> You look confused. <endif>

Additional Examples

<if stm lt 5> You have low stamina. <else> You're fine. <endif>
<if (race elf and has 2 arrows)> You fire twice. <endif>
<if flag companion_name eq "Marigold the Bold"> She smiles at you. <endif>

EBNF Definition

<expression>       ::= <term> { "or" <term> }

<term>             ::= <factor> { "and" <factor> }

<factor>           ::= "not" <factor>
                     | "(" <expression> ")"
                     | <atom>

<atom>             ::= <comparison>
                     | <function_call>

<comparison>       ::= <identifier> <comparison_op> <number_or_dice>
                     | "flag" <identifier> [<comparison_op> <string>]

<comparison_op>    ::= "eq" | "ne" | "lt" | "gt" | "lte" | "gte"

<number_or_dice>   ::= <number> | "dice"

<function_call>    ::= <identifier> { <argument> }

<argument>         ::= <identifier> | <number>

<identifier>       ::= [a-zA-Z_][a-zA-Z0-9_]*

<number>           ::= [0-9]+

<string>           ::= "\".*\""