命令百科

effect · get_supply_vehicles

Definition

  • Supported scope:COUNTRY
  • Supported target:none

Description

sets a variable to the number of supply vehicles in stockpile or that are needed. example 
get_supply_vehicles = { 
	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 常用于后勤相关 mod 中,动态检查某国库存卡车或火车数量,再据此触发事件或调整生产计划。例如在国家事件脚本里,先把库存数量写入变量,再与需求量比对,决定是否发出补给警告:

country_event = {
    id = logistics.1
    immediate = {
        get_supply_vehicles = {
            var = current_trucks
            type = truck
            need = no
        }
        get_supply_vehicles = {
            var = needed_trucks
            type = truck
            need = yes
        }
    }
    option = {
        # 用 current_trucks 与 needed_trucks 做后续比较
        trigger = { check_variable = { current_trucks < needed_trucks } }
        add_political_power = -20
    }
}

配合关系

  • [get_supply_vehicles_temp](/wiki/effect/get_supply_vehicles_temp):同为获取补给载具数量的命令,但结果存入临时变量,适合在同一 effect 块内做一次性计算,与 get_supply_vehicles 互补使用可同时保存持久与临时结果。
  • [get_supply_vehicles_temp](/wiki/trigger/get_supply_vehicles_temp):在 trigger 块中直接引用临时变量判断补给缺口,配合 get_supply_vehicles 先写值、后判断的两步流程形成完整逻辑闭环。
  • [add_equipment_to_stockpile](/wiki/effect/add_equipment_to_stockpile):当检测到库存低于需求后,可立即通过此命令向库存补充装备,构成"检测→补充"的自动化后勤脚本。
  • [add_fuel](/wiki/effect/add_fuel):与后勤资源管理主题高度相关,常在同一事件或决策中一并处理燃油与载具的资源调配逻辑。

常见坑

  1. need 字段含义混淆:新手容易误以为 need = yes 是"需要执行此命令"的开关,实际上它控制的是获取"当前需求量"而非"当前库存量"——两次调用分别设 need = noneed = yes,才能同时拿到库存与需求两个数值进行比较。
  2. 变量名冲突覆盖:两次调用若不慎使用同一个 var 名,后一次会直接覆盖前一次的结果,导致比较逻辑永远失效,务必为库存量和需求量分别指定不同变量名。