Hands-On Usage
any_collection_element is commonly used to iterate over a dynamically built scope collection and evaluate conditions against its elements — for example, checking whether at least one state controlled by a country meets a specific requirement. It is well-suited for complex research, war, or puppet-network logic as a cleaner alternative to deeply nested or chains.
# Check whether at least 2 states controlled by the current country have cores belonging to PREV
trigger = {
any_collection_element = {
collection = {
input = game:scope
operators = { controlled_states }
}
is_core_of = PREV
count = 2
}
}
Synergy
- all_collection_elements: The counterpart to
any_collection_element — where any_collection_element requires at least one matching element, all_collection_elements requires every element to match. The two are often used together against the same collection definition to compare partial versus full satisfaction.
- collection_size: Use
collection_size before any_collection_element to confirm the collection is non-empty, preventing empty collections from producing misleading logic results.
- count_triggers: When you need to tally how many distinct conditions are satisfied, combine
count_triggers with any_collection_element to build composite counting logic.
- every_collection_element: The effect-side counterpart. Once
any_collection_element evaluates to true, it is common practice to use every_collection_element inside an if block to perform batch operations on the same collection.
Common Pitfalls
- Misunderstanding
count: count means "at least N elements satisfy the condition," not "exactly N elements." If you need an exact match, you must bracket it with a not block using a higher count value — simply writing count = 3 does not mean "only 3 elements match."
- Wrong
input scope in the collection: The scope referenced in input = game:scope must be a valid scope pointer in the current context. Beginners often mistakenly write a hardcoded country tag or province ID there, causing the collection to fail to build and the condition to always evaluate as false.