命令百科

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(默认)取的是"库存里拥有多少辆"。新手常以为默认就是"需求量",把两种含义用反,导致判断逻辑完全相反。