trigger · if
Definition
- Supported scope:
any - Supported target:
none
Description
if_, CIfTrigger, A conditional trigger
if = { limit = { <triggers> } <trigger> }
ifanynoneif_, CIfTrigger, A conditional trigger
if = { limit = { <triggers> } <trigger> }
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.
The if trigger is commonly used in scenarios where you need to dynamically decide whether a condition is met based on different situations within the same conditional block. For example, within a limit block, you can conditionally allow event options, technologies, or decisions based on the current state. It enables "apply additional checks only when certain prerequisites are met" without requiring separate complete trigger chains for each branch.
# In a decision's available block: only if the player is a democratic nation,
# additionally require alliance war support
available = {
is_major = yes
if = {
limit = { has_government = democratic }
has_war_support > 0.5
}
}
[and](/wiki/trigger/and) / [or](/wiki/trigger/or) / [not](/wiki/trigger/not): Both the limit and main body of if can nest these logical compound triggers to construct complex branching conditions;[check_variable](/wiki/trigger/check_variable): Commonly placed in limit as a variable threshold for entering a branch, then additional checks are added in the main body; this is the standard pairing for variable-driven logic;[custom_trigger_tooltip](/wiki/trigger/custom_trigger_tooltip): When conditions inside if become complex, you can use this at the same level or outer layer to override the displayed text, preventing confusing raw condition lists from appearing in the UI;[if](/wiki/effect/if): The same-named command in effect blocks has completely parallel syntax to this trigger version. Understanding the distinction between the two (one judges, one executes) prevents mixing them up across effect and trigger contexts.if degenerates to always-true when limit is missing: When if lacks a limit, its main body conditions always participate in the evaluation, equivalent to writing the internal triggers directly at the outer level. Beginners often mistakenly think omitting limit will "skip" the branch, but the result is actually the opposite.if trigger into effect blocks: The if trigger is only valid in conditional contexts such as trigger/limit/available/allowed. If you mistakenly place it in execution blocks like immediate or option, you should use the effect version of if instead. While the syntax is similar, the context is different; confusing them causes scripts to silently fail or produce errors.