Hands-On Usage
meta_effect is well-suited for scenarios requiring dynamic concatenation of execution targets or values, such as deciding which country to execute an operation on based on a variable, or reusing the same logic across different parameters while avoiding large amounts of duplicate code. It is commonly used in generic event frameworks, dynamic alliance systems, or situations where you need to directly use country tags stored in script variables as scopes for execution.
# Add political power to a country tag stored in the target_country variable
meta_effect = {
text = {
[TARGET] = {
add_political_power = [AMOUNT]
}
}
TARGET = "var:target_country"
AMOUNT = "var:bonus_pp"
debug = no
}
Synergy
[set_variable](/wiki/effect/set_variable) / [set_temp_variable](/wiki/effect/set_temp_variable): Before calling meta_effect, first write the target tag or value into a variable, then reference it via var: syntax to pass it in. This is the most common prerequisite step.
[hidden_effect](/wiki/effect/hidden_effect): Wrap meta_effect inside hidden_effect to avoid exposing debugging processes or intermediate steps in player tooltips, keeping the UI clean.
[if](/wiki/effect/if): Add conditional checks outside the meta_effect to ensure the concatenated variables have been properly assigned and are valid, preventing errors from executing operations on empty tags.
[has_variable](/wiki/trigger/has_variable): Use as a condition for if to verify that variables passed to meta_effect actually exist before executing, avoiding silent failures caused by undefined variables.
Common Pitfalls
- Variables referenced via
var: must store country/State tags as strings, not numeric IDs: If a variable contains a numeric ID (like 42), passing it directly as a scope will fail to parse correctly. You need to pre-assign the correct string tag using set_variable.
- Placeholders in the
text block must exactly match the outer key names (case-sensitive): For example, [COUNTRY] requires COUNTRY = "..." in the outer layer. When spelling or casing mismatches occur, the game will not report an explicit error but will silently skip the entire effect block, making it extremely difficult to debug. It is strongly recommended to always keep debug = yes during development.