Wiki

effect · modify_project_flag

Definition

  • Supported scope:SPECIAL_PROJECT
  • Supported target:none

Description

modify project flag. Only modifies if flag already exists.
Example: modify_facility_flag = { flag = <name> value = <number> }

实战 · 配合 · 坑

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

实战用法

modify_project_flag 适用于需要对特殊项目上已有的数值型 flag 做累加或递减的场景,例如追踪某项目的研究阶段计数器或资源消耗累计值。注意它只会在 flag 已经存在时才生效,因此通常与初始化逻辑配合使用。典型场景是在项目每次推进时将进度标记加一:

# 在特殊项目的某个阶段触发块中
SPECIAL_PROJECT = {
    modify_project_flag = {
        flag = research_stage_counter
        value = 1
    }
}

配合关系

  • [set_project_flag](/wiki/effect/set_project_flag) — 用于在首次进入项目时初始化 flag 的初始值,确保后续 modify_project_flag 有旗标可操作。
  • [clr_project_flag](/wiki/effect/clr_project_flag) — 当累计值达到上限或阶段重置时,配合清除旗标以便重新开始计数周期。
  • [has_project_flag](/wiki/trigger/has_project_flag) — 在执行修改前用作条件检查,确认旗标存在并符合预期状态,避免逻辑错误。
  • [add_project_progress_ratio](/wiki/effect/add_project_progress_ratio) — 常在同一执行块中配合使用,在修改 flag 计数的同时推动项目实际进度,保持数据与进度同步。

常见坑

  1. 忘记预先初始化 flagmodify_project_flag 在 flag 不存在时静默失败,不会报错也不会创建新 flag,新手常因此误以为脚本正常运行,实际上计数器从未更新——务必先用 set_project_flag 赋予初始值。
  2. 在错误 scope 下调用:该 effect 仅在 SPECIAL_PROJECT scope 内有效,若在 country 或 state 等其他 scope 中调用不会产生任何效果,调试时难以察觉,需确认外层 scope 已正确切换至对应特殊项目。

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

modify_project_flag is useful for scenarios where you need to increment or decrement an existing numeric flag on a special project, such as tracking a research phase counter or cumulative resource consumption for that project. Note that it only takes effect when the flag already exists, so it typically works in conjunction with initialization logic. A typical use case is incrementing a progress marker each time the project advances:

# In a trigger block at a certain stage of the special project
SPECIAL_PROJECT = {
    modify_project_flag = {
        flag = research_stage_counter
        value = 1
    }
}

Synergy

  • [set_project_flag](/wiki/effect/set_project_flag) — Used to initialize the flag's initial value when first entering the project, ensuring that subsequent modify_project_flag calls have a flag to operate on.
  • [clr_project_flag](/wiki/effect/clr_project_flag) — When the accumulated value reaches its limit or a phase resets, use this to clear the flag and restart the counting cycle.
  • [has_project_flag](/wiki/trigger/has_project_flag) — Use as a conditional check before executing modifications to confirm the flag exists and is in the expected state, preventing logic errors.
  • [add_project_progress_ratio](/wiki/effect/add_project_progress_ratio) — Often used together in the same execution block, advancing actual project progress while modifying the flag counter to keep data and progress in sync.

Common Pitfalls

  1. Forgetting to initialize the flag beforehand: modify_project_flag fails silently when the flag doesn't exist—it won't produce an error or create a new flag. Beginners often mistakenly believe the script is working normally when in fact the counter never updates. Always use set_project_flag to assign an initial value first.
  2. Calling in the wrong scope: This effect only works within SPECIAL_PROJECT scope. If called in other scopes like country or state, it produces no effect and is difficult to detect during debugging. Always confirm that the outer scope has been correctly switched to the corresponding special project.