Wiki

effect · add_resource

Definition

  • Supported scope:STATE, COUNTRY
  • Supported target:none

Description

Adds/removes resource production to state

Example:
add_resource = {
  type = steel #resource type to add/destroy  amount = 5 #amount to add
  state = 42 #can be also read from scope
  days = 60 #a resource can be added/removed temporarily
  show_state_in_tooltip = no #Should we show in which state we add the resource(default = yes)?
}

实战 · 配合 · 坑

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

实战用法

add_resource 常用于事件或决策中动态调整某州的战略资源产量,例如科技解锁后增加钢铁/铝产量、或通过有时限的 buff 模拟临时资源开采协议。注意在 COUNTRY scope 下使用时必须通过 state 字段显式指定目标州编号,而在 STATE scope 下则可省略该字段直接从当前 scope 读取。

# 在一个决策的 complete_effect 中,给本国某州临时增加石油产量(60天后自动撤销)
complete_effect = {
    add_resource = {
        type = oil
        amount = 8
        state = 123
        days = 60
        show_state_in_tooltip = yes
    }
}

配合关系

  • [resource_count_trigger](/wiki/trigger/resource_count_trigger):在执行 add_resource 前用于检查目标州的当前资源数量,避免资源叠加超出合理范围或满足"达到阈值才触发"的条件判断。
  • [add_state_modifier](/wiki/effect/add_state_modifier):常与 add_resource 搭配,在同一事件选项中既直接增加资源产量又附加修正值(如产出加成),实现更完整的"资源开发"效果。
  • [add_building_construction](/wiki/effect/add_building_construction):通常在同一逻辑块中配合使用,先建造基础设施再增加资源,体现资源开发的完整流程。
  • [free_building_slots](/wiki/trigger/free_building_slots):在决策可用条件中检查州内是否有足够建筑槽,与资源增减决策形成逻辑上的前置约束。

常见坑

  1. 在 COUNTRY scope 下忘写 state 字段add_resource 在国家 scope 下执行时若不指定 state,脚本会报错或静默失效,因为国家本身没有资源概念,必须明确指向一个具体的州编号。
  2. 混淆"产量"与"库存"add_resource 修改的是州的资源生产量(每周产出),而非当前战略资源库存数量,新手常误以为它等同于直接往仓库里加资源,实际效果是永久(或限时)改变该州的每周产出数值。

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

add_resource is commonly used in events or decisions to dynamically adjust resource production in a state, such as increasing steel/aluminum output after unlocking a technology, or simulating temporary resource extraction agreements through limited-duration modifiers. Note that when used in COUNTRY scope, you must explicitly specify the target state ID via the state field, whereas in STATE scope this field can be omitted and the current scope is used directly.

# In a decision's complete_effect, temporarily add oil production to a state (automatically removed after 60 days)
complete_effect = {
    add_resource = {
        type = oil
        amount = 8
        state = 123
        days = 60
        show_state_in_tooltip = yes
    }
}

Synergy

  • [resource_count_trigger](/wiki/trigger/resource_count_trigger): Use before executing add_resource to check the current resource count in the target state, preventing resource stacking beyond reasonable limits or to satisfy "trigger only if threshold is met" conditional logic.
  • [add_state_modifier](/wiki/effect/add_state_modifier): Often paired with add_resource in the same event option to both directly increase resource production and apply modifiers (such as production bonuses), achieving a more complete "resource development" effect.
  • [add_building_construction](/wiki/effect/add_building_construction): Typically used together in the same logic block—build infrastructure first, then increase resources—to reflect the complete workflow of resource development.
  • [free_building_slots](/wiki/trigger/free_building_slots): Check in decision availability conditions whether the state has sufficient building slots, forming a logical prerequisite constraint with resource increase/decrease decisions.

Common Pitfalls

  1. Forgetting the state field in COUNTRY scope: When add_resource executes in country scope without specifying state, the script will error or silently fail, since a country itself has no resource concept and must explicitly target a specific state ID.
  2. Confusing "production" with "stockpile": add_resource modifies a state's resource production rate (weekly output), not the current strategic resource inventory quantity. Newcomers often mistakenly believe it directly adds resources to storage; in reality, it permanently (or temporarily) changes that state's weekly output value.