Wiki

trigger · has_resources_in_collection

Definition

  • Supported scope:COUNTRY
  • Supported target:none

Description

Checks for amount of resources in a given collection.

	### Example
	```
	has_resources_in_collection = {
		collection = {
				game:scope
				operators =  { country_and_all_subjects }
		}
		resource = chromium
		amount > 10
		extracted = yes # (optional, default: no) checks extracted amount instead of country balance
		buildings = no # (optional, default: no) checks only amount from local buildings instead of country balance
		Note: extracted and buildings are mutually exclusive
	}
	```

实战 · 配合 · 坑

实战内容由 AI 生成,并已对照 vanilla 命令词表校验 —— 请当作起点而非权威依据。上方的定义节才是游戏自带文档原文。

实战用法

常用于检测某个国家连同其附庸国整体的战略资源储备是否达标,例如在决策或国策的 available 块中限制只有铬矿产出充足的国家才能走特定科技路线。collection 字段的灵活性使其适合多方联合资源池检测,而非单纯检查本国库存。

available = {
    has_resources_in_collection = {
        collection = {
            game:scope
            operators = { country_and_all_subjects }
        }
        resource = chromium
        amount > 20
        extracted = yes
    }
}

配合关系

  • [count_in_collection](/wiki/trigger/count_in_collection):同样接受 collection 写法,可先用它统计集合内满足条件的成员数量,再配合本 trigger 确认资源总量,形成"人数 + 资源"双重门槛。
  • [any_subject_country](/wiki/trigger/any_subject_country):当需要进一步细化检查是哪个附庸提供了资源时,可用它逐一遍历附庸,与本 trigger 的集合总量结果互补。
  • [add_resource](/wiki/effect/add_resource):常见于 effect 块:触发条件满足后向特定地区追加资源,与本 trigger 构成"检测不足 → 补充"的逻辑闭环。
  • [create_import](/wiki/effect/create_import):若本 trigger 判定资源不足,可在 else 分支用此 effect 自动创建进口协议来弥补缺口。

常见坑

  1. extractedbuildings 互斥却同时填写:两者只能选其一,同时出现会导致脚本报错或行为未定义;省略两者时默认检查的是国家资源余额(balance),三种模式含义不同,务必根据实际需求明确选择。
  2. collection 写法遗漏 operators:只写 game:scope 而不附 operators 子块,集合将退化为只含当前国家自身,导致附庸或盟友的资源无法被纳入统计,产生结果偏低的隐性 bug。

Hands-On Notes

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.

Hands-On Usage

Commonly used to check whether a country and its subject nations collectively meet resource stockpile requirements. For example, in the available block of a decision or national focus to restrict access to specific technology paths only for nations with sufficient chromium production. The flexibility of the collection field makes it suitable for multi-party resource pool detection rather than simply checking domestic reserves.

available = {
    has_resources_in_collection = {
        collection = {
            game:scope
            operators = { country_and_all_subjects }
        }
        resource = chromium
        amount > 20
        extracted = yes
    }
}

Synergy

  • [count_in_collection](/wiki/trigger/count_in_collection): Similarly accepts collection syntax and can first count members within the collection that meet conditions, then combine with this trigger to verify total resource volume, forming a dual threshold of "headcount + resources".
  • [any_subject_country](/wiki/trigger/any_subject_country): When needing to further refine which subject nation provided the resources, use it to iterate through subjects one by one, complementing the aggregate results of this trigger's collection.
  • [add_resource](/wiki/effect/add_resource): Commonly found in effect blocks: upon triggering conditions being met, append resources to specific regions, forming a complete logic loop of "detect shortage → supplement" with this trigger.
  • [create_import](/wiki/effect/create_import): If this trigger determines resources are insufficient, use this effect in the else branch to automatically create import agreements to fill the gap.

Common Pitfalls

  1. extracted and buildings are mutually exclusive yet filled simultaneously: Only one can be chosen; simultaneous appearance will cause script errors or undefined behavior. When both are omitted, the default checked value is the nation's resource balance, and the three modes have different meanings—be sure to explicitly select based on actual requirements.
  2. collection syntax missing operators: Writing only game:scope without the operators sub-block causes the collection to degenerate into containing only the current nation itself, preventing subject or ally resources from being included in the calculation, resulting in a silent bug with understated results.