Wiki

effect · set_state_name

Definition

  • Supported scope:STATE
  • Supported target:none

Description

set_state_name = <string> - Set the current states name

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

set_state_name is commonly used in narrative-driven mods, such as renaming a state to its historical name after an event trigger, or assigning custom administrative division names to new governments in occupation/liberation scenarios. Combined with state_event, naming changes can be displayed in real-time as the story progresses, enhancing immersion.

# Rename a state in an event option
option = {
    name = my_event.1.a
    set_state_name = "New Republic Territory"
}

Synergy

  • [reset_state_name](/wiki/effect/reset_state_name): Used to restore the default name when a naming task is completed or conditions are revoked. It is the inverse operation of set_state_name, and the two should be used in pairs to ensure a complete name lifecycle.
  • [set_state_flag](/wiki/effect/set_state_flag) / [has_state_flag](/wiki/trigger/has_state_flag): First use a flag to record the "renamed" status, then use a trigger to prevent duplicate triggers, avoiding the same state being overwritten multiple times.
  • [set_state_owner_to](/wiki/effect/set_state_owner_to): In occupation scenarios, the state's owner is often changed simultaneously with assigning a new name. Both commands are typically written in the same option or hidden_effect block.
  • [state_event](/wiki/effect/state_event): Immediately trigger a subsequent event after completing the rename, forming a complete narrative chain of "rename → popup notification".

Common Pitfalls

  1. Scope Error: set_state_name must be executed under STATE scope. Beginners often call it directly in COUNTRY scope without first switching to the specific state, resulting in script errors or silent failures. The correct approach is to first use <state_id> = { set_state_name = "..." } to explicitly enter the state scope.
  2. Localization Key Misunderstanding: This command accepts a direct string rather than a localization key name. Entering a localization key name (such as MY_STATE_NAME) will not automatically translate it; the game will display the key string as-is. If multilingual support is needed, it requires coordination with other text replacement methods or confirmation of the engine version's actual behavior before deciding on a strategy.