Wiki

trigger · count_triggers

Definition

  • Supported scope:any
  • Supported target:none

Description

Returns true if the specified number of sub-triggers return true
count_triggers = { amount = 2 <trigger> <trigger> <trigger> }

Hands-On Notes

Hands-on notes are AI-generated and checked against the vanilla command vocabulary — treat them as a starting point, not authoritative reference. The definition above is the game's own documentation.

Hands-On Usage

count_triggers is ideal for scenarios requiring "a certain number of conditions out of several possibilities" with fuzzy threshold logic. For example, determining whether a country meets at least two conditions among multiple categories like population, industry, and political stability—without requiring all conditions to be satisfied. Compared to deeply nested or/and chains, it makes code intent clearer and easier to maintain.

# Example: A decision triggers only if the country meets at least 2 conditions
available = {
    count_triggers = {
        amount = 2
        has_war = no
        has_global_flag = special_event_flag
        threat < 0.5
        is_historical_focus_on = yes
    }
}

Synergy

  • [and](/wiki/trigger/and) / [or](/wiki/trigger/or): count_triggers itself does not support logical nesting semantics. Use and/or within its sub-triggers to construct compound sub-conditions, enabling fine-grained control over "satisfy N out of X compound conditions."
  • [custom_trigger_tooltip](/wiki/trigger/custom_trigger_tooltip): The tooltip text for count_triggers can be hard to read in the UI. It is recommended to wrap the entire block with custom_trigger_tooltip to provide player-friendly localized descriptions.
  • [check_variable](/wiki/trigger/check_variable): When the threshold amount needs to vary dynamically based on variables, use check_variable at the outer level first to evaluate the variable before deciding whether to enter the count_triggers logic block.
  • [if](/wiki/trigger/if): In complex condition blocks, if can be used to dynamically decide whether to evaluate the entire count_triggers based on different scenarios, avoiding unnecessary performance overhead.

Common Pitfalls

  1. amount exceeds the total number of sub-triggers: If amount is set to a value larger than the actual number of listed sub-triggers, the trigger will permanently return false without error reporting, making it very difficult to troubleshoot. Always manually verify the count of sub-conditions.
  2. Mistaking order for evaluation priority: Beginners often assume count_triggers will "evaluate earlier items first," but in reality it evaluates all sub-triggers and counts how many return true. There is no short-circuit evaluation, so be mindful of performance impact when dealing with many sub-triggers.