Wiki

trigger · is_debug

Definition

  • Supported scope:any
  • Supported target:any

Description

returns true if game is in debug mode (launched with -debug argument)

实战 · 配合 · 坑

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

实战用法

is_debug 常用于在 mod 开发阶段插入仅调试时生效的日志输出、强制触发条件或跳过繁琐前置要求,方便测试而不影响正式发布版本的玩家体验。例如在事件可用条件中加入调试分支,或在 focus 的 available 块里临时绕过某些限制:

available = {
    OR = {
        is_debug = yes
        AND = {
            has_global_flag = some_prerequisite_flag
            date > 1939.1.1
        }
    }
}

配合关系

  • [has_global_flag](/wiki/trigger/has_global_flag):调试模式下常结合全局标记快速切换测试状态,is_debug 作为外层保护确保该逻辑不影响正式游戏。
  • [log](/wiki/effect/log):在 hidden_effect 或 if 块中与 is_debug 搭配,仅当调试模式开启时向日志文件输出变量或状态信息,避免正式运行时产生大量无用日志。
  • [if](/wiki/trigger/if):几乎总是把 is_debug 套在 if 块内使用,在 effect 上下文中有条件地执行仅供调试的操作。
  • [hidden_effect](/wiki/effect/hidden_effect):将调试用的副作用包裹在 hidden_effect + is_debug = yes 组合中,既隐藏提示信息又保证只在开发环境生效。

常见坑

  1. 忘记在发布前移除或保护调试分支:直接将 is_debug = yes 写在 available 或 trigger 的顶层而不用 OR/if 保护,会导致非调试模式下条件永远为假,普通玩家完全无法触发该内容。
  2. 误以为可以在普通单机游戏中动态开关is_debug 取决于游戏启动参数 -debug,无法通过任何 effect 在运行时修改,用它来做"可切换的作弊开关"是无效的设计思路。

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

is_debug is commonly used during mod development to insert debug-only log outputs, force condition triggers, or bypass cumbersome prerequisites for easier testing without affecting the player experience in the official release. For example, you can add a debug branch within an event's availability conditions, or temporarily bypass certain restrictions in a focus's available block:

available = {
    OR = {
        is_debug = yes
        AND = {
            has_global_flag = some_prerequisite_flag
            date > 1939.1.1
        }
    }
}

Synergy

  • [has_global_flag](/wiki/trigger/has_global_flag): In debug mode, commonly paired with global flags to quickly toggle test states; is_debug serves as an outer guard to ensure this logic doesn't affect regular gameplay.
  • [log](/wiki/effect/log): Used together with is_debug within hidden_effect or if blocks to output variable or state information to the log file only when debug mode is enabled, avoiding excessive useless logs during official runs.
  • [if](/wiki/trigger/if): Almost always wrap is_debug inside an if block when used in effect contexts to conditionally execute debug-only operations.
  • [hidden_effect](/wiki/effect/hidden_effect): Enclose debug-specific side effects in a hidden_effect + is_debug = yes combination to both hide notification messages and ensure they only take effect in development environments.

Common Pitfalls

  1. Forgetting to remove or protect debug branches before release: Writing is_debug = yes directly at the top level of available or trigger without OR/if protection will cause the condition to always evaluate to false in non-debug mode, making the content completely inaccessible to regular players.
  2. Assuming it can be dynamically toggled in regular single-player games: is_debug depends on the game launch parameter -debug and cannot be modified at runtime by any effect; using it as a "toggleable cheat switch" is an ineffective design approach.