Wiki

effect · reset_state_name

Definition

  • Supported scope:STATE
  • Supported target:none

Description

reset_state_name = yes - Resets the current states name to the original one

实战 · 配合 · 坑

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

实战用法

reset_state_name 常用于动态改名 mod 中,在某段事件或决议结束后将地块名称恢复为原始状态,避免临时命名"遗留"在地图上。例如在一个占领期间给某州临时起军管名称、占领解除后再还原的场景:

# 占领结束事件的 option 中
option = {
    name = my_event.1.a
    # 还原州名
    every_state = {
        limit = {
            has_state_flag = temp_renamed_state
        }
        reset_state_name = yes
        clr_state_flag = temp_renamed_state
    }
}

配合关系

  • [set_state_name](/wiki/effect/set_state_name) — 先用它给州设置临时名称,之后再用 reset_state_name 还原,两者构成"改名→复原"的完整流程。
  • [set_state_flag](/wiki/effect/set_state_flag) / [clr_state_flag](/wiki/effect/clr_state_flag) — 配合旗帜标记"该州曾被重命名",在触发还原时用旗帜作为过滤条件,避免误操作其他州。
  • [has_state_flag](/wiki/trigger/has_state_flag) — 在 limit 块中检查旗帜,确保只对真正被改名的州执行还原,防止范围过宽。

常见坑

  1. 作用域错误reset_state_name 必须在 STATE scope 下执行,若写在国家或省份 scope 里会静默失效,新手常忘记先用 every_state/capital_scope 等切换到正确 scope。
  2. 误以为会清除 set_state_name 以外的改名:该命令仅还原被脚本修改过的名称到本地化文件中定义的原始州名,若原始名称本身在本地化文件里就有错误,reset_state_name 不会"修复"它,排查 bug 时需先检查本地化条目。

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

reset_state_name is commonly used in dynamic renaming mods to restore a state's name to its original state after a certain event or decision concludes, preventing temporary names from "lingering" on the map. For example, in a scenario where you give a state a temporary military administration name during occupation and then restore it after the occupation ends:

# In the option of an occupation end event
option = {
    name = my_event.1.a
    # Restore state name
    every_state = {
        limit = {
            has_state_flag = temp_renamed_state
        }
        reset_state_name = yes
        clr_state_flag = temp_renamed_state
    }
}

Synergy

  • [set_state_name](/wiki/effect/set_state_name) — Use this first to set a temporary name for the state, then use reset_state_name to restore it afterward, forming a complete "rename→restore" workflow.
  • [set_state_flag](/wiki/effect/set_state_flag) / [clr_state_flag](/wiki/effect/clr_state_flag) — Work together with flags to mark "this state has been renamed," then use the flag as a filter condition when triggering restoration, preventing accidental operations on other states.
  • [has_state_flag](/wiki/trigger/has_state_flag) — Check the flag in the limit block to ensure only truly renamed states execute the restoration, preventing overly broad scope.

Common Pitfalls

  1. Scope error: reset_state_name must execute under STATE scope; writing it in country or province scope will silently fail. Beginners often forget to first switch to the correct scope using every_state/capital_scope or similar constructs.
  2. Mistaking it as clearing all renames besides set_state_name: This command only restores names modified by scripts back to the original state names defined in localization files. If the original name itself has errors in the localization file, reset_state_name won't "fix" it. When debugging, first check the localization entries.