Hands-On Usage
any_of is commonly used to iterate over a custom array and check whether at least one element satisfies a specific condition — for example, checking whether any value stored in an array of country tags or numbers meets a threshold, in order to control the availability of event options or a focus's available block.
# Check whether any index in the array target_states has a corresponding variable value greater than 5
available = {
any_of = {
array = target_states
value = current_val
index = i
check_variable = {
var = current_val
value = 5
compare = greater_than
}
}
}
Synergy
- add_to_array / add_to_temp_array: The most typical "write-then-read" pairing pattern — populate the array on the effect side first, then use
any_of on the trigger side to iterate and check.
- all_of: Semantically complementary to
any_of. While all_of requires every element in the array to satisfy the condition, any_of only requires one. The two are often combined to express complex logic.
- check_variable: The most common check used inside an
any_of loop body, used to perform numerical comparisons against the current iteration value (value) or a related variable.
- count_triggers: When you need to know how many elements satisfy a condition rather than simply whether any do, this can be used alongside or as a replacement for
any_of for more precise quantity-based checks.
Common Pitfalls
- Missing the
array field or a typo in the array name: any_of requires array = <array_name> to be specified. If the array has not yet been initialized via add_to_array or add_to_temp_array when the trigger is evaluated, the loop body will not execute and any_of will immediately return false — causing the condition to silently never be met.
- Naming the
value/index placeholder variables the same as existing global variables: value and index are temporary variable names scoped to the current iteration. If they share a name with a variable set elsewhere via set_variable, they may unexpectedly overwrite or read incorrect values during the loop. Use unique, descriptive names (e.g., value = my_loop_val) to avoid polluting the variable namespace.