trigger · is_in_array
Definition
- Supported scope:
any - Supported target:
none
Description
Checks if an element is in array
Example: is_in_array = {
array = array_name
value = 42
}
#shorter usage: is_in_array = { array_name = 42 }
is_in_arrayanynoneChecks if an element is in array
Example: is_in_array = {
array = array_name
value = 42
}
#shorter usage: is_in_array = { array_name = 42 }
Hands-on notes are AI-generated and checked against the vanilla command vocabulary — treat them as a starting point, not authoritative reference. The definition above is the game's own documentation.
is_in_array is commonly found in mod scenarios that require tracking "processed countries/states" or "selected option lists". For example, checking whether a country TAG or value has already been added to a custom queue array, thereby preventing duplicate event or effect triggers.
# Check if the current country's TAG variable is already in the "visited countries" array
if = {
limit = {
is_in_array = {
array = visited_countries_array
value = THIS
}
}
# Already in array, skip processing
custom_effect_tooltip = already_visited_tt
}
[add_to_array](/wiki/effect/add_to_array) — First add elements to the array, then use is_in_array to verify successful insertion, or prevent duplicate additions in subsequent triggers.[remove_from_array](/wiki/effect/remove_from_array) — Pair with is_in_array to form a safe "check-then-remove" pattern, avoiding logic errors from removing non-existent elements.[collection_size](/wiki/trigger/collection_size) — Commonly used in the same array logic block: first confirm the array is non-empty and contains the target element, then perform further size comparisons.[check_variable](/wiki/trigger/check_variable) — Frequently combined: check_variable validates numeric conditions, is_in_array validates membership, and both together form composite guard conditions.is_in_array to always return false silently, making debugging extremely difficult.