trigger · log
Definition
- Supported scope:
any - Supported target:
none
Description
Print message to game.log - Can be localized
loganynonePrint message to game.log - Can be localized
实战内容由 AI 生成,并已对照 vanilla 命令词表校验 —— 请当作起点而非权威依据。上方的定义节才是游戏自带文档原文。
log trigger 常用于 mod 调试阶段,在复杂条件链或事件触发时向 game.log 输出变量状态或流程节点,帮助确认脚本是否按预期执行。由于它在任意 scope 下均可使用,常被临时插入 limit、trigger 或 available 块中辅助排查问题。
# 在事件触发条件中埋入日志,确认某国是否通过了检查
trigger = {
log = "DEBUG: [This.GetTag] is checking war trigger block"
has_global_flag = some_mod_flag
is_debug = yes
}
[is_debug](/wiki/trigger/is_debug):配合使用可确保日志输出仅在调试模式下生效,避免正式发布的 mod 污染玩家日志文件。[check_variable](/wiki/trigger/check_variable):在变量判断前后各插一条 log,可追踪变量值是否符合预期,快速定位逻辑错误。[has_global_flag](/wiki/trigger/has_global_flag):配合 log 在 flag 检查点前后打印状态,确认全局 flag 的设置时序是否正确。[log](/wiki/effect/log)(effect 侧同名命令):effect 块中同样存在 log,调试时可在 trigger 和 effect 两侧同时埋点,对比条件判断与实际执行的差异。log trigger 本身不影响游戏逻辑,但大量日志输出会拖慢性能并让玩家的 game.log 膨胀,正式发布前务必用 is_debug = yes 包裹或直接删除。log 支持本地化 key,但新手常误将本地化 key 和普通字符串混用,导致日志输出的是 key 名而非预期文本,需确认本地化文件中对应条目已正确定义。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.
The log trigger is commonly used during mod debugging to output variable states or execution checkpoints to game.log in complex condition chains or event triggers, helping verify that scripts execute as intended. Since it can be used in any scope, it is often temporarily inserted into limit, trigger, or available blocks to troubleshoot issues.
# Embed logging in event trigger conditions to confirm whether a country passes the check
trigger = {
log = "DEBUG: [This.GetTag] is checking war trigger block"
has_global_flag = some_mod_flag
is_debug = yes
}
[is_debug](/wiki/trigger/is_debug): Using it together ensures log output only takes effect in debug mode, preventing published mods from polluting the player's log file.[check_variable](/wiki/trigger/check_variable): Insert log statements before and after variable checks to track whether variable values match expectations and quickly locate logic errors.[has_global_flag](/wiki/trigger/has_global_flag): Pair log with flag checkpoints to print status before and after, confirming the initialization sequence of global flags is correct.[log](/wiki/effect/log) (same-named command on the effect side): The effect block also contains log; during debugging you can instrument both trigger and effect sides simultaneously to compare discrepancies between condition evaluation and actual execution.log trigger itself does not affect game logic, but excessive log output will degrade performance and bloat the player's game.log. Before official release, always wrap with is_debug = yes or delete directly.log supports localization keys, but beginners often mix localization keys with plain strings, causing the log output to show the key name rather than intended text. Confirm that corresponding entries in localization files are properly defined.