Wiki

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 名,后一次会直接覆盖前一次的结果,导致比较逻辑永远失效,务必为库存量和需求量分别指定不同变量名。

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 is commonly used in logistics-related mods to dynamically check a country's inventory of trucks or trains, then trigger events or adjust production plans accordingly. For example, in a country event script, you can first store the inventory count in a variable, then compare it against the demand, and decide whether to issue a supply warning:

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 = {
        # Use current_trucks and needed_trucks for subsequent comparison
        trigger = { check_variable = { current_trucks < needed_trucks } }
        add_political_power = -20
    }
}

Synergy

  • [get_supply_vehicles_temp](/wiki/effect/get_supply_vehicles_temp): Another command for retrieving supply vehicle counts, but stores the result in a temporary variable instead. Best suited for one-time calculations within the same effect block. Use alongside get_supply_vehicles to simultaneously preserve both persistent and temporary results.
  • [get_supply_vehicles_temp](/wiki/trigger/get_supply_vehicles_temp): Directly references temporary variables in trigger blocks to assess supply shortages. Combined with get_supply_vehicles in a two-step workflow—first write values, then evaluate—forms a complete logical loop.
  • [add_equipment_to_stockpile](/wiki/effect/add_equipment_to_stockpile): After detecting that inventory falls below demand, immediately replenish stockpiles with this command, creating an automated logistics script following the "detect → replenish" pattern.
  • [add_fuel](/wiki/effect/add_fuel): Highly relevant to logistics resource management themes. Often handled together with get_supply_vehicles in the same event or decision to manage both fuel and vehicle allocation logic.

Common Pitfalls

  1. Confusion over the need field: Beginners often mistakenly think need = yes is a switch meaning "execute this command." In reality, it controls whether to retrieve the "current demand" rather than the "current inventory"—you must call the command twice, once with need = no and once with need = yes, to obtain both inventory and demand values for comparison.
  2. Variable name collision and overwrite: If two calls accidentally use the same var name, the second call will directly overwrite the first result, breaking your comparison logic entirely. Always assign different variable names for inventory and demand quantities.