Wiki

effect · clr_country_flag

Definition

  • Supported scope:COUNTRY
  • Supported target:none

Description

clear country flag

实战 · 配合 · 坑

实战内容由 AI 生成,并已对照 vanilla 命令词表校验 —— 请当作起点而非权威依据。上方的定义节才是游戏自带文档原文。

实战用法

clr_country_flag 常用于事件链或决策链的收尾阶段,清除之前用 set_country_flag 埋下的状态标记,防止旧标记干扰后续逻辑判断。例如一段外交事件触发后需要重置"已发出警告"状态:

country_event = {
    id = my_mod.5
    option = {
        name = my_mod.5.a
        # 事件处理完毕,清除之前设置的警告标记
        clr_country_flag = warned_target_flag
    }
}

配合关系

  • [has_country_flag](/wiki/trigger/has_country_flag):最典型的搭档——先用该触发器检查标记是否存在,再决定是否清除,避免无效操作或逻辑错乱。
  • [country_event](/wiki/effect/country_event):清除标记后通常紧接着触发下一个事件,确保新事件在"干净"的标记环境下运行。
  • [add_ideas](/wiki/effect/add_ideas):部分 mod 用国家标记来追踪某个国策/理念的激活状态,清除标记时往往同步移除对应理念,两者成对出现。
  • [activate_targeted_decision](/wiki/effect/activate_targeted_decision):决策的可见/可用条件经常依赖国家标记,清除标记可直接影响该决策是否继续显示,常配合使用以控制决策树流程。

常见坑

  1. 标记名拼写不一致set_country_flag 时用的是 my_event_done,清除时却写成 my_event_Done,由于标记名区分大小写,会导致清除失效、旧标记永久残留,后续 has_country_flag 检查一直为真。
  2. 在错误 scope 下调用:该命令只对 COUNTRY scope 有效,若在 state scope(如 every_owned_state 内部)直接调用,需要先用 owner = { clr_country_flag = ... } 切回国家 scope,否则脚本会静默报错或不生效。

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

clr_country_flag is commonly used in the final stages of event or decision chains to clear status markers previously set with set_country_flag, preventing stale flags from interfering with subsequent logic checks. For example, after a diplomatic event is resolved, you may need to reset a "warning issued" state:

country_event = {
    id = my_mod.5
    option = {
        name = my_mod.5.a
        # Event processing complete, clear the previously set warning flag
        clr_country_flag = warned_target_flag
    }
}

Synergy

  • [has_country_flag](/wiki/trigger/has_country_flag): The most typical companion—first use this trigger to check if the flag exists, then decide whether to clear it, avoiding redundant operations or logic conflicts.
  • [country_event](/wiki/effect/country_event): After clearing a flag, it's common to immediately fire the next event, ensuring the new event executes in a "clean" flag environment.
  • [add_ideas](/wiki/effect/add_ideas): Some mods use country flags to track the activation state of a focus/idea, and when clearing flags, the corresponding idea is often removed in sync. The two often appear as a paired operation.
  • [activate_targeted_decision](/wiki/effect/activate_targeted_decision): Decision visibility/availability conditions frequently depend on country flags. Clearing a flag can directly control whether that decision continues to display. These are commonly used together to manage decision tree flow.

Common Pitfalls

  1. Inconsistent flag name spelling: You set my_event_done with set_country_flag, but clear it as my_event_Done. Since flag names are case-sensitive, the clear operation will fail and the stale flag persists indefinitely, causing subsequent has_country_flag checks to always return true.
  2. Calling in the wrong scope: This command only works in COUNTRY scope. If called directly within a state scope (e.g., inside every_owned_state), you must first switch back to country scope using owner = { clr_country_flag = ... }. Otherwise, the script will silently error or have no effect.