Wiki

trigger · get_supply_vehicles_temp

Definition

  • Supported scope:COUNTRY
  • Supported target:none

Description

sets a temp variable to the number of supply vehicles in stockpile or that are needed. example 
get_supply_vehicles_temp = { 
	var = num_vehicles #variable to set 
	type = truck #can be truck or train 
	need = yes #default no. If yes, gets the number of needed vehicles 
}

实战 · 配合 · 坑

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

实战用法

get_supply_vehicles_temp 常用于需要动态检测某国补给车辆库存或缺口的场景,例如在决策的 available 块中判断卡车储备是否充足,或在事件触发条件里评估补给缺口大小再给出相应选项。配合变量比较,可实现"库存不足时才解锁紧急征购决策"之类的逻辑。

# 决策的 available 块:仅当卡车库存低于所需时才开放紧急补给决策
available = {
    get_supply_vehicles_temp = {
        var = needed_trucks
        type = truck
        need = yes
    }
    get_supply_vehicles_temp = {
        var = owned_trucks
        type = truck
        need = no
    }
    check_variable = { owned_trucks < needed_trucks }
}

配合关系

  • [get_supply_vehicles](/wiki/effect/get_supply_vehicles):非临时变量版本,直接把车辆数写入持久变量;当需要跨事件保留数据时用它,而 get_supply_vehicles_temp 只在当前作用域生效,两者互补。
  • [get_supply_vehicles_temp](/wiki/effect/get_supply_vehicles_temp)(在 effect 块中使用):该命令同时也是 effect,可在 effect 块里赋值后立即用 check_variable 做后续逻辑判断,形成"赋值→判断→执行"流水线。
  • [add_equipment_to_stockpile](/wiki/effect/add_equipment_to_stockpile):获取缺口数量后,常与此 effect 配合,将差额卡车直接补入库存,实现数值精确补货。
  • [has_country_flag](/wiki/trigger/has_country_flag):在判断链中通常先用国家标记做粗筛,再调用 get_supply_vehicles_temp 做精确数值判断,避免每帧重复执行昂贵的变量运算。

常见坑

  1. 忘记区分临时变量生命周期get_supply_vehicles_temp 写入的是 temp 变量,仅在当前脚本执行帧内有效,不能跨 event option 或跨 on_action 读取。新手常把它设在一个事件选项里,然后在另一个选项或后续 effect 块里引用,结果变量已被清空读到 0。
  2. need = yesneed = no 语义混淆need = yes 取的是"当前缺少多少辆",need = no(默认)取的是"库存里拥有多少辆"。新手常以为默认就是"需求量",把两种含义用反,导致判断逻辑完全相反。

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

get_supply_vehicles_temp is commonly used in scenarios where you need to dynamically detect a country's supply vehicle inventory or shortfall, such as checking truck reserves in a decision's available block or evaluating supply gaps in event triggers to present relevant options. Combined with variable comparisons, you can implement logic like "unlock emergency procurement decisions only when inventory is insufficient."

# In a decision's available block: open emergency supply decision only when truck inventory falls below required amount
available = {
    get_supply_vehicles_temp = {
        var = needed_trucks
        type = truck
        need = yes
    }
    get_supply_vehicles_temp = {
        var = owned_trucks
        type = truck
        need = no
    }
    check_variable = { owned_trucks < needed_trucks }
}

Synergy

  • [get_supply_vehicles](/wiki/effect/get_supply_vehicles): Non-temporary variable version that directly writes vehicle counts to persistent variables; use this when you need to retain data across events, whereas get_supply_vehicles_temp only works within the current scope—they complement each other.
  • [get_supply_vehicles_temp](/wiki/effect/get_supply_vehicles_temp) (when used in effect blocks): This command functions as both trigger and effect, allowing you to assign values in an effect block and immediately use check_variable for subsequent logic judgments, creating an "assign → check → execute" pipeline.
  • [add_equipment_to_stockpile](/wiki/effect/add_equipment_to_stockpile): After obtaining shortage quantities, this effect is commonly paired to directly replenish the difference in truck inventory, achieving precise numerical restocking.
  • [has_country_flag](/wiki/trigger/has_country_flag): In judgment chains, typically use country flags first for coarse filtering, then invoke get_supply_vehicles_temp for precise numerical judgment, avoiding expensive variable calculations repeated every frame.

Common Pitfalls

  1. Forgetting to distinguish temporary variable lifespans: Values written by get_supply_vehicles_temp are temp variables, valid only within the current script execution frame and cannot be read across event options or different on_action calls. Beginners often set it in one event option then reference it in another option or subsequent effect block, only to find the variable has been cleared and reads 0.
  2. Confusing the semantics of need = yes and need = no: need = yes retrieves "how many are currently lacking," while need = no (default) retrieves "how many are currently in stock." Beginners often assume the default means "required amount," using the two meanings backwards and resulting in completely inverted judgment logic.