Wiki

effect · clr_state_flag

Definition

  • Supported scope:STATE
  • Supported target:none

Description

clear state flag

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_state_flag is used to clear flags previously set via set_state_flag after completing a specific task phase, allowing you to reset state machines or enable events/decisions to trigger again. Typical scenarios include: clearing temporary flags used to track construction progress, resetting related workflow flags after a region's control status changes.

# When a region is fully controlled, clear the temporary construction flag to allow the next-phase decision to appear again
state_event = {
    id = my_mod.101
    ...
    option = {
        name = my_mod.101.a
        clr_state_flag = region_under_construction
    }
}

Synergy

  • [has_state_flag](/wiki/trigger/has_state_flag): Use this trigger to check if the flag exists before clearing it, avoiding logic conflicts or duplicate clears.
  • [set_state_flag](/wiki/effect/set_state_flag): The two form a complete flag lifecycle management system—one sets, one clears—and are the standard pairing for state machine design.
  • [modify_state_flag](/wiki/effect/modify_state_flag): If you need to modify a numeric flag rather than clear it outright, you can combine it with clr_state_flag to create a "reset-then-reinitialize" pattern.
  • [state_event](/wiki/effect/state_event): Clearing a flag often immediately triggers a new event to advance the narrative or task flow to the next phase.

Common Pitfalls

  1. Wrong scope: clr_state_flag can only execute in STATE scope. Calling it within a country or province scope will fail silently without error messages. Beginners often make this mistake due to confused scope nesting levels—carefully verify that the outer scope has already switched to the state.
  2. Clearing non-existent flags produces no error but creates logic hazards: The game won't error if you clear a flag that was never set, but if a trigger depending on that flag completes its check before the clear due to other logic running first, the state machine will skip expected steps. Always pair with [has_state_flag](/wiki/trigger/has_state_flag) for pre-clearing validation.