effect · set_state_name
Definition
- Supported scope:
STATE - Supported target:
none
Description
set_state_name = <string> - Set the current states name
set_state_nameSTATEnoneset_state_name = <string> - Set the current states name
实战内容由 AI 生成,并已对照 vanilla 命令词表校验 —— 请当作起点而非权威依据。上方的定义节才是游戏自带文档原文。
set_state_name 常用于动态叙事类 mod,例如在事件触发后将某个州的名称改为历史上曾用的地名,或在占领/解放剧本中赋予新政权自定义的行政区划名称。配合 state_event 可在故事线推进时即时呈现命名变化,增强沉浸感。
# 事件选项中将某州重命名
option = {
name = my_event.1.a
set_state_name = "新共和国特区"
}
[reset_state_name](/wiki/effect/reset_state_name):当命名任务完成或条件撤销时用于恢复默认名称,是 set_state_name 的逆操作,二者成对使用保证名称生命周期完整。[set_state_flag](/wiki/effect/set_state_flag) / [has_state_flag](/wiki/trigger/has_state_flag):先用 flag 记录"已重命名"状态,再用 trigger 防止重复触发,避免同一州被多次覆盖命名。[set_state_owner_to](/wiki/effect/set_state_owner_to):占领剧本中往往同时更换州的所有者并赋予新名称,两条命令通常写在同一 option 或 hidden_effect 块内。[state_event](/wiki/effect/state_event):在完成重命名后立即触发后续事件,形成"改名 → 弹窗通知"的完整叙事链。set_state_name 必须在 STATE scope 下执行。新手常在 COUNTRY scope 中直接调用而不先切换到具体州,导致脚本报错或静默失效;正确做法是先用 <state_id> = { set_state_name = "..." } 明确进入州 scope。MY_STATE_NAME)不会自动转译,游戏会原样显示键名字符串;若需要多语言支持,需要配合其他文本替换手段或确认引擎版本的实际行为后再决策。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.
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"
}
[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".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.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.