effect · save_global_event_target_as
Definition
- Supported scope:
any - Supported target:
none
Description
save a global event target
save_global_event_target_asanynonesave a global event target
实战内容由 AI 生成,并已对照 vanilla 命令词表校验 —— 请当作起点而非权威依据。上方的定义节才是游戏自带文档原文。
save_global_event_target_as 常用于需要跨事件、跨国家 scope 传递特定对象引用的场景,例如在全局剧情链中记录"触发战争的国家"或"当前谈判目标",以便后续任何事件都能通过 event_target:xxx 直接引用该对象,而无需重复查找。典型应用包括多国联动的外交事件链、全局阵营领袖追踪、以及跨 scope 的动态国家标记。
# 在某个事件的 immediate 块中,将当前国家保存为全局目标
immediate = {
save_global_event_target_as = negotiation_initiator
}
# 之后任意事件或 effect 中,可直接引用:
# event_target:negotiation_initiator = { ... }
[clear_global_event_target](/wiki/effect/clear_global_event_target):保存全局目标后,在剧情链结束或目标失效时应及时清除,避免残留的无效引用污染后续逻辑。[save_event_target_as](/wiki/effect/save_event_target_as):局部版本的目标保存,常与全局版本搭配使用——先用局部目标在当前事件内做临时计算,确认后再用全局版本持久化存储。[has_event_target](/wiki/trigger/has_event_target):在使用 event_target:xxx 前先检查目标是否存在,防止因全局目标未被正确保存而导致的脚本报错。[if](/wiki/effect/if):配合条件判断,仅在满足特定条件时才执行保存操作,避免意外覆盖已有的全局目标引用。save_global_event_target_as 都会无声地覆盖旧值。多条事件链共用同一个目标名时,极易出现"后来者覆盖先来者"的竞争问题,务必为不同链路使用唯一命名。clear_global_event_target 进行清理。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.
save_global_event_target_as is commonly used in scenarios requiring cross-event, cross-country scope passing of specific object references. For example, in global story chains, you can record the "country that triggered a war" or "current negotiation target" so that any subsequent event can directly reference that object via event_target:xxx without repeated lookups. Typical applications include multi-country coordinated diplomatic event chains, global faction leader tracking, and dynamic country marking across scopes.
# In the immediate block of an event, save the current country as a global target
immediate = {
save_global_event_target_as = negotiation_initiator
}
# In any subsequent event or effect, you can directly reference:
# event_target:negotiation_initiator = { ... }
[clear_global_event_target](/wiki/effect/clear_global_event_target): After saving a global target, promptly clear it when the story chain concludes or the target becomes invalid, preventing stale references from polluting subsequent logic.[save_event_target_as](/wiki/effect/save_event_target_as): The local version of target saving, commonly paired with the global version—use the local target for temporary calculations within the current event, then persist the result using the global version.[has_event_target](/wiki/trigger/has_event_target): Check whether the target exists before using event_target:xxx to prevent script errors caused by the global target not being correctly saved.[if](/wiki/effect/if): Combine with conditional checks to execute the save operation only when specific conditions are met, avoiding accidental overwriting of existing global target references.save_global_event_target_as is called from any scope. When multiple event chains share the same target name, a "late-comer overwrites early-comer" race condition easily occurs. Always use unique naming for different execution paths.clear_global_event_target to clean up when the event chain ends.