Hands-On Usage
all_of is typically used when you need to iterate over an array and verify that every element satisfies a given condition — for example, checking whether all country tags stored in an array actually exist, or confirming that a set of province variables all meet a numeric threshold. As the counterpart to any_of, all_of requires every member to pass before returning true, making it the right tool for strict "no exceptions allowed" validation.
# Check whether every country tag stored in the temporary array target_countries exists
all_of = {
array = target_countries
value = v
country_exists = v
}
Synergy
- add_to_temp_array — Push target values into a temporary array one by one on the effect side, then use
all_of on the trigger side to validate them all at once. This "collect → verify" pattern is the most common use case.
- any_of — Semantically complementary to
all_of. On the same array, you can use any_of for a loose preliminary check and then all_of for strict filtering, building a layered condition chain.
- clear_temp_array — Clear the temporary array promptly after a loop finishes to prevent leftover data from a previous iteration from contaminating
all_of's evaluation.
- check_variable — The go-to sub-condition inside
all_of for performing concrete numeric comparisons on each element of the array; it is one of the most frequently used triggers inside loop bodies.
Common Pitfalls
- Default variable name collisions:
value defaults to the temporary variable v, and index defaults to i. If outer logic already uses temporary variables named v or i, the inner loop will silently overwrite them, corrupting the outer data. Always explicitly specify non-conflicting names such as value = my_val.
- Empty arrays return true: When the supplied array has zero elements,
all_of has nothing to evaluate and returns true immediately (a universal statement over an empty set is vacuously true in formal logic). If your logic requires the array to be non-empty in order to pass, add an extra check_variable outside all_of to confirm the array's collection_size is greater than 0.