Hands-On Usage
check_expr is commonly used in scenarios that require dynamically computing a combination of multiple variables — for example, checking whether a country's total industrial value, population pressure index, or custom score exceeds a threshold, without having to write deeply nested check_variable conditions. Typical use cases include triggering special events based on a weighted sum of variables, or validating complex formula conditions inside an available block.
# Check whether "variable A multiplied by 2, plus variable B" is greater than 10
available = {
check_expr = {
value = var:my_score_var
multiply = 2
add = var:bonus_var
greater_than = 10
}
}
Synergy
- check_variable:
check_variable only supports simple single-value comparisons. When a comparison requires multi-step arithmetic, switch to check_expr — the two are complementary alternatives to each other.
- set_variable / add_to_variable: Write intermediate results into variables using these effects first, then reference them inside
check_expr. This makes expressions easier to read and reuse.
- count_triggers: When you need to satisfy both a set of logical conditions and a numeric calculation threshold, nest
check_expr with count_triggers to handle logical counting and mathematical computation separately.
- custom_trigger_tooltip: Wrap
check_expr with this to provide players with a readable localized description, preventing the UI from displaying blank text or cryptic internal formulas.
Common Pitfalls
- Forgetting comparison fields such as
greater_than / less_than: The official behavior of check_expr is "true if the result is non-zero." If you only write arithmetic fields without a comparison operator, the expression returns whether the computed result itself is non-zero — not the "greater than some value" check you intended. Always explicitly include a comparison condition at the end; otherwise, if the value happens to be zero, the trigger will silently return false with no error.
- Writing effect-side variable commands (such as
add_to_variable) inside a trigger block: check_expr is a trigger and only accepts mathematical expression parameters internally — effect commands cannot be mixed in. If you need to compute a value and then assign it, use set_temp_variable (or similar) inside an effect block to perform the assignment first, then reference that temporary variable inside the trigger block for evaluation.