Wiki

trigger · always

Definition

  • Supported scope:any
  • Supported target:any

Description

always returns specified value

实战 · 配合 · 坑

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

实战用法

always 最常见的用途是临时屏蔽或强制启用某段逻辑,例如在调试 mod 时将某个复杂 trigger 块整体替换为 always = yes 来验证后续 effect 是否正常触发,或用 always = no 让某个事件选项暂时不可选。在正式发布的 mod 里,也常用于 if / or / not 结构的"兜底"分支,确保逻辑链在任何情况下都有明确的出口。

# 调试用:强制让某事件选项始终可用
option = {
    name = MY_EVENT.1.a
    trigger = {
        always = yes   # 临时绕过复杂条件,调试通过后替换回真实 trigger
    }
    # ... effects ...
}

配合关系

  • ifif 需要一个 limit 条件块,用 always = no 可以将整个 if 分支临时禁用,便于逐段调试复杂逻辑。
  • not — 配合 not = { always = yes } 可构造一个永远为假的条件,常用于占位或注释掉某段 trigger 而不删除代码。
  • or — 在 or 结构末尾加 always = no 作为语义占位符,保持代码可读性,明确表达"当前没有其他满足条件的分支"。
  • custom_trigger_tooltip — 调试时将真实条件替换为 always = yes/no 后,搭配 custom_trigger_tooltip 可以在 UI 中显示自定义说明文字,方便测试界面表现而无需满足真实前提。

常见坑

  1. always = yes 留在发布版本里:调试完毕后忘记还原,导致本应有门槛的事件选项或决策对所有国家/任何时刻都开放,破坏游戏平衡。建议在代码中用注释 # DEBUG 标记所有临时使用的 always,发布前统一搜索清理。
  2. 误以为 always 能接受变量或表达式always 只接受字面量 yesno,不能写成 always = { check_variable = { ... } } 这样的嵌套形式——需要动态判断时应改用 [check_variable](/wiki/trigger/check_variable) 等专用 trigger,直接在 always 里套子块会导致解析错误或静默失效。

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

always is most commonly used to temporarily disable or force-enable a block of logic, such as during mod debugging by replacing a complex trigger block entirely with always = yes to verify that subsequent effects trigger correctly, or using always = no to temporarily make an event option unavailable. In released mods, it's also frequently used as a "fallback" branch in if / or / not structures to ensure the logic chain has a clear exit under any circumstances.

# Debug use: force an event option to always be available
option = {
    name = MY_EVENT.1.a
    trigger = {
        always = yes   # Temporarily bypass complex conditions; replace with actual trigger after debugging
    }
    # ... effects ...
}

Synergy

  • ifif requires a limit condition block; using always = no allows you to temporarily disable an entire if branch for step-by-step debugging of complex logic.
  • not — combining not = { always = yes } constructs a condition that is always false, commonly used for placeholders or commenting out trigger blocks without deleting code.
  • or — add always = no at the end of an or structure as a semantic placeholder to maintain code readability and explicitly express "no other branches currently satisfy the conditions."
  • custom_trigger_tooltip — when debugging, after replacing actual conditions with always = yes/no, pair it with custom_trigger_tooltip to display custom descriptive text in the UI, facilitating interface testing without needing to satisfy the actual prerequisites.

Common Pitfalls

  1. Leaving always = yes in the released version: forgetting to restore it after debugging, causing event options or decisions that should have prerequisites to become available to all nations/at any time, breaking game balance. It's recommended to mark all temporarily-used always statements with # DEBUG comments in the code, then perform a unified search and cleanup before release.
  2. Mistakenly believing always can accept variables or expressions: always only accepts literal values yes or no; you cannot write it as always = { check_variable = { ... } } in nested form — when dynamic evaluation is needed, use dedicated triggers like [check_variable](/wiki/trigger/check_variable) instead. Nesting sub-blocks directly in always will cause parse errors or silent failures.