Skip to content

Condition System

Conditions decide whether an operation is allowed to continue. They are used by recipes, strengthening, skills, items, GUI buttons, and actions.

Unified block

Modules use condition as the unified condition block entry. CoreLib parses it through ConditionBlock.

yaml
condition:
  type: all_of
  entries:
    - '%player_level% >= 10'
    - '%money% >= 1000'
  required_count: 0
  invalid_as_failure: true
FieldMeaning
condition.typeCombination mode: all_of, any_of, none_of, at_least, or exactly.
condition.entriesCondition entries.
condition.required_countRequired passing count for at_least and exactly.
condition.invalid_as_failureTreat invalid configuration as failure.
condition.on_pass.actionsActions to run when the condition passes, when supported by the caller.
condition.on_fail.actionsActions to run when the condition fails, when supported by the caller.
condition.on_fail.block_outputBlock output on failure, used by output-producing modules such as Cooking.
condition.on_fail.messageFailure message for modules such as Item equipment checks.

Nested groups are written as entries with their own type and entries:

yaml
condition:
  type: all_of
  entries:
    - type: any_of
      entries:
        - '%vip_level% >= 1'
        - '%player_level% >= 50'
    - '%money% >= 5000'

Advice

Use clear failure messages for players. For important restrictions, keep invalid configuration as failure to avoid bypasses.