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
- 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.
- 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.