Wiki

effect · set_province_name

Definition

  • Supported scope:any
  • Supported target:none

Description

set_province_name = { id = <province id> name = <string> } - Set name for a province

实战 · 配合 · 坑

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

实战用法

set_province_name 常用于历史事件或剧本 mod 中,当某省份因战争、条约或文化变迁而需要更名时(如将德语地名改为波兰语地名)。也可在动态领土事件中,配合国家占领逻辑为前线省份赋予新的战时称呼。

# 某国通过条约取得省份后,将省份重命名
country_event = {
    id = my_mod.42
    immediate = {
        set_province_name = {
            id = 3210
            name = "Neu_Königsberg"
        }
    }
}

配合关系

  • [reset_province_name](/wiki/effect/reset_province_name):与本命令互为逆操作,当玩家失去该领土或事件回滚时,用于还原省份原名,避免残留错误名称。
  • [add_victory_points](/wiki/effect/add_victory_points):常在同一 option 中配合使用,重命名省份的同时调整其战略价值,使叙事与机制变化同步生效。
  • [custom_effect_tooltip](/wiki/effect/custom_effect_tooltip):由于省份重命名在 UI 上反馈不明显,配合此命令向玩家显示一条说明性提示,提升 mod 可读性。
  • [set_victory_points](/wiki/effect/set_victory_points):在省份更名伴随政治意义变化的场景下,同步重设胜利点数量,确保地图状态与新命名含义一致。

常见坑

  1. id 填的是省份 ID 而非州 ID:新手容易把 state ID(数百级别)和 province ID(数千级别)混淆,导致命令静默失败或作用到错误省份,务必在 /Hearts of Iron IV/map/definition.csv 中核实具体的省份编号。
  2. 名称字符串未做本地化处理:直接在 name 字段写带空格或特殊字符的明文字符串可能导致解析异常;推荐使用本地化键名(localisation key),并在对应的 .yml 文件中定义译文,以保证多语言兼容性。

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_province_name is commonly used in historical events or scenario mods when a province needs to be renamed due to war, treaties, or cultural changes (such as renaming German place names to Polish ones). It can also be used in dynamic territory events, combined with occupation logic to assign new wartime designations to frontline provinces.

# After a country acquires a province through treaty, rename the province
country_event = {
    id = my_mod.42
    immediate = {
        set_province_name = {
            id = 3210
            name = "Neu_Königsberg"
        }
    }
}

Synergy

  • [reset_province_name](/wiki/effect/reset_province_name): Inverse operation to this command; used to restore the original province name when the player loses the territory or when an event is rolled back, preventing residual incorrect names.
  • [add_victory_points](/wiki/effect/add_victory_points): Commonly used in combination within the same option; rename the province while adjusting its strategic value, ensuring narrative and mechanical changes take effect simultaneously.
  • [custom_effect_tooltip](/wiki/effect/custom_effect_tooltip): Since province renaming provides minimal UI feedback, pair this command with it to display an explanatory tooltip to the player, improving mod readability.
  • [set_victory_points](/wiki/effect/set_victory_points): In scenarios where province renaming is accompanied by changes in political significance, simultaneously reset the victory points to ensure the map state aligns with the new naming's meaning.

Common Pitfalls

  1. id refers to province ID rather than state ID: Newcomers often confuse state ID (hundreds magnitude) with province ID (thousands magnitude), causing the command to fail silently or apply to the wrong province. Always verify the specific province number in /Hearts of Iron IV/map/definition.csv.
  2. Name string lacks localization processing: Writing plaintext strings with spaces or special characters directly in the name field may cause parsing errors; it is recommended to use localization keys and define translations in the corresponding .yml files to ensure multi-language compatibility.