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 
}

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.