cargo_util¶
Source: base/tealdef/gui/main/cargo_util.d.tl
Notes
Functions that collect cargo data for the UI: stock contents of industries, warehouses and
town buildings, cargo loaded in vehicles and on lines, cargo type icons, names and colours,
and cargo flow counts. All functions read engine state and do not change it. Load it with
ug_require "/gui/main/cargo_util.tl".
CargoUtil¶
record global base/tealdef/gui/main/cargo_util.d.tl:3
global record CargoUtil
Load: local cargo_util = ug_require "/gui/main/cargo_util.tl"
Notes
Read-only helpers for cargo types, stocks and vehicle cargo in the UI.
Details
Cargo type ids (CargoTypeId) are 0-based. Engine arrays indexed by cargo type, such as
TransportVehicle.config.capacities, are 1-based Lua arrays, so entry i belongs to cargo
type i - 1.
Functions
getCargoTypesCount(producedOnly : boolean) : integer base/tealdef/gui/main/cargo_util.d.tl:4
Call as cargo_util.getCargoTypesCount
producedOnly: only current types in game if true, all available from rep if false
Returns integer
getMaxCaroTypeId() : integer base/tealdef/gui/main/cargo_util.d.tl:5
Call as cargo_util.getMaxCaroTypeId
Notes
Returns the highest cargo type id in api.res.cargoTypeRep.getAll(true).
Returns integer
Details
The name is spelled Caro in the game files.
getPassengerCargoTypeId() : CargoTypeId base/tealdef/gui/main/cargo_util.d.tl:6
Call as cargo_util.getPassengerCargoTypeId
Notes
Returns the cargo type id of passengers (api.res.cargoTypeRep.getPassengerCargoTypeId()).
Returns CargoTypeId
Used in the base game: 42 times in 24 files
base/content/mission/mission/tasks/town_rating/town_rating.tl:58
base/content/gui/gui/layers/layer_passenger_flow.tl:77
base/content/gui/gui/layers/layer_cargo_flow.tl:203
base/content/gui/gui/layers/layer_public_transport.tl:55
base/content/gui/gui/layers/layer_cargo.tl:77
base/content/gui/gui/debug_panel/make_entity_debug_panel.tl:454
… and 18 more files.
calculateStockConfigs(entity : Engine.Entity, max? : integer, calculateQuality? : boolean, sortByType? : boolean, showEmpty? : boolean, groupStocks? : boolean, producedOnly? : boolean) : {CargoUtil.StockConfig}, integer, boolean base/tealdef/gui/main/cargo_util.d.tl:21
Call as cargo_util.calculateStockConfigs
Notes
Groups the stocks of a stock list entity and computes stored amount, capacity, tendency and optionally quality per group.
| Parameter | Type | Description |
|---|---|---|
entity |
Engine.Entity |
Stock list entity (e.g. Industry.stockList or Warehouse.stockList). |
max? |
integer |
Maximum number of cargo icons the caller wants to show per row; adjusted and returned as the second result. |
calculateQuality? |
boolean |
If true, fills quality and numSpoiled. |
sortByType? |
boolean |
If true, sorts the groups by stock type, then by cargo types. |
showEmpty? |
boolean |
If false, leaves out empty stocks (default true). |
groupStocks? |
boolean |
If false, makes one entry per stock instead of grouping stocks by type and cargo types (default true). |
producedOnly? |
boolean |
If true, only lists cargo types that are produced in the current game. |
Returns {CargoUtil.StockConfig}, integer, boolean: 1. List of StockConfig. 2. The adjusted maximum icon count. 3. true if at least one group is not an output stock.
Details
Returns an empty list if the entity does not exist.
Used in the base game: 7 times in 5 files
base/content/mission/mission/tasks/transport_cargo/empty_stocks.tl:75
local stockConfigs, __, __ = cargo_util.calculateStockConfigs(stockListEntity, maxIconsInput, calculateQuality, sortByType)
base/content/gui/gui/main/hud_icon_toolbox.tl:207
stockConfigs, dummyA, dummyB = cargo_util.calculateStockConfigs(params.entity, nil, true, true, true)
base/content/gui/gui/main/cargo_react_util.tl:624
base/content/gui/gui/statistics/statistic_warehouses.tl:54
base/content/gui/gui/entity_window/entity_window_util.tl:508
sortConfigsByStockType({CargoUtil.StockConfig}, boolean) : {CargoUtil.StockConfig} base/tealdef/gui/main/cargo_util.d.tl:23
Call as cargo_util.sortConfigsByStockType
input-, output-, storage stock
Returns {CargoUtil.StockConfig}
calculateStockCargoCount(Engine.Entity, ?boolean, ?{StockId}, ?boolean) : {StockCargoCount} base/tealdef/gui/main/cargo_util.d.tl:37
Call as cargo_util.calculateStockCargoCount
entity: id of entity holding the according stock, eg. industry, warehouse... sortByCargoType: [optional] if true, we sort by cargo type otherwise by cargo count, default is false stock ids: [optional] must be stocks of given industry/warehouse entity, if given count is calculated only for those, otherwise for all stocks of given industry/warehouse calculateQuality : [optional] if true, quality is calculated
Returns {StockCargoCount}
Used in the base game: 3 times in 3 files
base/content/gui/gui/main/hud_icon_toolbox.tl:62
base/content/gui/gui/statistics/statistic_warehouses.tl:379
base/content/gui/gui/entity_window/entity_window_util.tl:1760
calculateSortedVehicleCargoInfo(Engine.Entity, calculateQuality? : boolean) : {VehicleCargo} base/tealdef/gui/main/cargo_util.d.tl:47
Call as cargo_util.calculateSortedVehicleCargoInfo
Notes
Lists the cargo capacities of a vehicle, sorted by capacity (highest first), then by cargo type.
| Parameter | Type | Description |
|---|---|---|
#1 |
Engine.Entity |
Vehicle entity with a TRANSPORT_VEHICLE component. |
calculateQuality? |
boolean |
If true, fills hasGoodCargo and hasBadCargo. |
Returns {VehicleCargo}
calculateSortedVehicleCargoInfoCompareValue(Engine.Entity) : {{CargoTypeId, integer, integer}} base/tealdef/gui/main/cargo_util.d.tl:50
Call as cargo_util.calculateSortedVehicleCargoInfoCompareValue
get value usable to for sorting (so that cargoType is most significant)
Returns {{CargoTypeId, integer, integer}}
calculateSortedLineCargoInfo(lineEntity : Engine.Entity, calculateQuality? : boolean) : {CargoUtil.VehicleCargo} base/tealdef/gui/main/cargo_util.d.tl:52
Call as cargo_util.calculateSortedLineCargoInfo
Notes
Like calculateSortedVehicleCargoInfo, summed over all vehicles of a line.
| Parameter | Type | Description |
|---|---|---|
lineEntity |
Engine.Entity |
Line entity. |
calculateQuality? |
boolean |
If true, fills hasGoodCargo and hasBadCargo. |
Returns {CargoUtil.VehicleCargo}
Used in the base game: 2 times in 2 files
base/content/gui/gui/line_vehicle_mgmt/manager_window.tl:2556
base/content/gui/gui/statistics/statistic_lines.tl:333
calculateSortedLineCargoInfoCompareValue(lineEntity : Engine.Entity) : {{CargoTypeId, integer, integer}} base/tealdef/gui/main/cargo_util.d.tl:53
Call as cargo_util.calculateSortedLineCargoInfoCompareValue
Notes
Returns {cargoType, fill, capacity} for each cargo type of a line's vehicles, in the same order as calculateSortedLineCargoInfo. Used as a sort key.
Returns {{CargoTypeId, integer, integer}}
hasLineVehicleWithCapacity(lineEntity : Engine.Entity, cargoTypeId : CargoTypeId) : boolean base/tealdef/gui/main/cargo_util.d.tl:54
Call as cargo_util.hasLineVehicleWithCapacity
Notes
Tells whether any vehicle of a line can carry the cargo type, based on TransportVehicle.config.allCaps.
Returns boolean
calculateVehicleCargoFill({Engine.Entity}, integer) : integer base/tealdef/gui/main/cargo_util.d.tl:56
Call as cargo_util.calculateVehicleCargoFill
Notes
Returns the number of loaded items of one cargo type summed over the given vehicles.
| Parameter | Type | Description |
|---|---|---|
#1 |
{Engine.Entity} |
Vehicle entities. |
#2 |
integer |
Cargo type id. |
Returns integer
getSortedProducedCargoTypes(locationParams : CargoLocationParams, sortOrder : CargoListSortOrder, passengersFirst? : boolean, cargoTypeFilter? : (function(CargoTypeId) : boolean), allLineCapacities? : boolean) : {CargoTypeId} base/tealdef/gui/main/cargo_util.d.tl:104
Call as cargo_util.getSortedProducedCargoTypes
Notes
Lists the cargo types present at a location, limited to cargo types produced in the current game, sorted by the given order.
| Parameter | Type | Description |
|---|---|---|
locationParams |
CargoLocationParams |
Locations to count. |
sortOrder |
CargoListSortOrder |
Sort order. |
passengersFirst? |
boolean |
If true, moves passengers to the front. |
cargoTypeFilter? |
(function(CargoTypeId) : boolean) |
Function that returns true for cargo types to keep. |
allLineCapacities? |
boolean |
Passed to api.engine.util.line.getLineCapacityUsages for line locations. |
Returns {CargoTypeId}
Details
In the game's implementation cargoTypeFilter only takes effect in the shortcut case
(only vehicleEntity set, showEmpty off, sort order CAPACITY); in all other cases the
list is returned unfiltered.
Used in the base game: 7 times in 6 files
base/content/gui/gui/line_vehicle_mgmt/line_react_util.tl:689
sortedCargoTypes = cargo_util.getSortedProducedCargoTypes(locationParams, "CAPACITY", nil, nil, true)
base/content/gui/gui/main/cargo_react_util.tl:401
local cargoTypes = cargo_util.getSortedProducedCargoTypes(overriddenParams, params.sortOrder, true, params.cargoTypeFilter)
base/content/gui/gui/statistics/statistic_lines.tl:67
base/content/gui/gui/statistics/statistics_react_util.tl:236
base/content/gui/gui/statistics/statistic_vehicles.tl:78
base/content/gui/gui/entity_window/entity_window_util.tl:2205
getConfiguredStopCargoTypes(stopParams : CargoStopParams, passengersFirst? : boolean) : {CargoTypeId} base/tealdef/gui/main/cargo_util.d.tl:111
Call as cargo_util.getConfiguredStopCargoTypes
Notes
Lists the cargo types set to load at a line stop (stopConfig.load).
| Parameter | Type | Description |
|---|---|---|
stopParams |
CargoStopParams |
Line and stop. |
passengersFirst? |
boolean |
If true, moves passengers to the front. |
Returns {CargoTypeId}: Cargo type ids, or an empty list if the stop does not exist.
getNumberOfCargoInStock(stockListOwnerEntity : Engine.Entity) : integer base/tealdef/gui/main/cargo_util.d.tl:115
Call as cargo_util.getNumberOfCargoInStock
Notes
Returns the total number of cargo items in the stock list of an industry, warehouse or town building.
Returns integer: Item count, 0 if the entity has no stock list.
getCargoTypeInfo(CargoTypeId, CargoLocationParams) : CargoTypeInfo base/tealdef/gui/main/cargo_util.d.tl:116
Call as cargo_util.getCargoTypeInfo
Notes
Collects amount, capacity, quality and, for vehicles, loading state of one cargo type at the given locations.
| Parameter | Type | Description |
|---|---|---|
#1 |
CargoTypeId |
Cargo type id. |
#2 |
CargoLocationParams |
Locations to count; the values of all set locations are added up. |
Returns CargoTypeInfo
Used in the base game: 4 times in 3 files
base/content/gui/gui/main/cargo_react_util.tl:405
base/content/gui/gui/statistics/statistics_react_util.tl:239
base/content/gui/gui/entity_window/entity_window_util.tl:2212
getSpecializationClasses(stockListEntity : Engine.Entity) : {string} base/tealdef/gui/main/cargo_util.d.tl:117
Call as cargo_util.getSpecializationClasses
Notes
Returns the cargo class names a stock list is specialized for.
Returns {string}
Details
Collects the included cargo classes of storage stocks that only filter by included cargo classes (no excluded classes, no included cargo types).
getCargoClassesOfType(CargoTypeId) : {CargoClassId} base/tealdef/gui/main/cargo_util.d.tl:119
Call as cargo_util.getCargoClassesOfType
Notes
Returns the ids of the cargo classes of a cargo type. Unknown class tags are skipped.
Returns {CargoClassId}
getWarehouseCountIndicatorTexture(integer) : string base/tealdef/gui/main/cargo_util.d.tl:121
Call as cargo_util.getWarehouseCountIndicatorTexture
Notes
Returns the arrow icon for a stock tendency value.
| Parameter | Type | Description |
|---|---|---|
#1 |
integer |
Tendency from -3 to 3; values beyond are clamped. |
Returns string: Image path, e.g. ::/gui/entity_window/icons/stock_increasing2.tga; stock_stagnating.tga for 0.
getCargoColorById(CargoTypeId) : Vec4f base/tealdef/gui/main/cargo_util.d.tl:122
Call as cargo_util.getCargoColorById
Notes
Returns the colour of a cargo type with alpha 1.
Returns Vec4f
getCargoColorByType(string) : Vec4f base/tealdef/gui/main/cargo_util.d.tl:123
Call as cargo_util.getCargoColorByType
Notes
Returns the colour of a cargo type given by its name in the cargo type repository.
Returns Vec4f
Details
Returns the darkest neutral colour of default_colors.gres for nil.
getCargoIconById(CargoTypeId) : string base/tealdef/gui/main/cargo_util.d.tl:124
Call as cargo_util.getCargoIconById
Notes
Returns the icon path of a cargo type.
Returns string
Used in the base game: 20 times in 15 files
base/content/gui/gui/line_vehicle_mgmt/vehicle_store_window.tl:160
base/content/gui/gui/line_vehicle_mgmt/manager_hud_util.tl:239
base/content/gui/gui/construction/construction_desc_react_util.tl:431
base/content/gui/gui/construction/construction.tl:3150
base/content/gui/gui/construction/construction_react_util.tl:1609
base/content/gui/gui/main/hud_icon_toolbox.tl:66
… and 9 more files.
getCargoIconByType(string) : string base/tealdef/gui/main/cargo_util.d.tl:125
Call as cargo_util.getCargoIconByType
Notes
Returns the icon path of a cargo type given by its name in the cargo type repository; "" for nil.
Returns string
getCargoClassIconById(CargoClassId) : string base/tealdef/gui/main/cargo_util.d.tl:126
Call as cargo_util.getCargoClassIconById
Notes
Returns the icon path of a cargo class.
Returns string
getMixedCargoIcon() : string base/tealdef/gui/main/cargo_util.d.tl:127
Call as cargo_util.getMixedCargoIcon
Notes
Returns the icon for mixed or any cargo (::/cargos/icons/cargo_mixed.tga).
Returns string
Used in the base game: 6 times in 5 files
base/content/gui/gui/line_vehicle_mgmt/vehicle_store_util.tl:1145
base/content/gui/gui/construction/construction.tl:3359
base/content/gui/gui/main/cargo_react_util.tl:507
base/content/gui/gui/statistics/statistic_warehouses.tl:96
base/content/gui/gui/entity_window/entity_window_util.tl:314
getPassengerCargoIcon() : string base/tealdef/gui/main/cargo_util.d.tl:128
Call as cargo_util.getPassengerCargoIcon
Notes
Returns the passenger icon (::/cargos/passengers/passengers.tga).
Returns string
Used in the base game: 3 times in 3 files
base/content/gui/gui/construction/construction.tl:3356
base/content/gui/gui/main/hud_icon_toolbox.tl:130
base/content/gui/gui/entity_window/station_group/station_group.tl:135
getCargoNameById(CargoTypeId) : string base/tealdef/gui/main/cargo_util.d.tl:129
Call as cargo_util.getCargoNameById
Notes
Returns the display name of a cargo type.
Returns string
Used in the base game: 17 times in 13 files
base/content/gui/gui/debug_panel/make_entity_debug_panel.tl:448
base/content/gui/gui/line_vehicle_mgmt/vehicle_store_window.tl:165
base/content/gui/gui/line_vehicle_mgmt/manager_window.tl:2558
base/content/gui/gui/statistics/statistic_warehouses.tl:386
base/content/gui/gui/statistics/statistic_lines.tl:335
base/content/gui/gui/statistics/statistic_industries.tl:461
… and 7 more files.
getCargoNameByType(string) : string base/tealdef/gui/main/cargo_util.d.tl:130
Call as cargo_util.getCargoNameByType
Notes
Returns the display name of a cargo type given by its name in the cargo type repository; "" for nil.
Returns string
getStockListEntityFromOwner(stockListOwnerEntity : Engine.Entity) : Engine.Entity base/tealdef/gui/main/cargo_util.d.tl:132
Call as cargo_util.getStockListEntityFromOwner
Notes
Returns the stock list entity of a town building, industry or warehouse.
Returns Engine.Entity: The stockList of the owner's TOWN_BUILDING, INDUSTRY or WAREHOUSE component, or nil.
getInputOutputStocksForStation(stationEntity : Engine.Entity, skipStorage? : boolean) : {CargoTypeId : boolean}, integer, {CargoTypeId : boolean}, integer base/tealdef/gui/main/cargo_util.d.tl:134
Call as cargo_util.getInputOutputStocksForStation
Notes
Collects the input and output cargo types of all stock lists in a station's catchment area.
| Parameter | Type | Description |
|---|---|---|
stationEntity |
Engine.Entity |
Station entity. |
skipStorage? |
boolean |
See getInputOutputStocksForStockList. |
Returns {CargoTypeId : boolean}, integer, {CargoTypeId : boolean}, integer: 1. Set of input cargo types. 2. Number of input entries (one per stock and cargo type, summed over all stock lists). 3. Set of output cargo types. 4. Number of output entries.
Used in the base game: 5 times in 2 files
base/content/gui/gui/line_vehicle_mgmt/cargofilter_window.tl:346
local inputCargoTypes, inputCount, outputCargoTypes, _outputCount = cargo_util.getInputOutputStocksForStation(stationGroup.stations[stop.station + 1])
base/content/gui/gui/line_vehicle_mgmt/line_util.tl:553
getInputOutputStocksForStockList(stationEntity : Engine.Entity, skipStorage? : boolean) : {CargoTypeId : boolean}, integer, {CargoTypeId : boolean}, integer base/tealdef/gui/main/cargo_util.d.tl:136
Call as cargo_util.getInputOutputStocksForStockList
Notes
Collects the input and output cargo types of one stock list.
| Parameter | Type | Description |
|---|---|---|
stationEntity |
Engine.Entity |
Stock list entity (the parameter name is misleading). |
skipStorage? |
boolean |
If true, only input and output stocks count. Otherwise storage stocks count as both input and output. |
Returns {CargoTypeId : boolean}, integer, {CargoTypeId : boolean}, integer: 1. Set of input cargo types. 2. Number of input entries (one per stock and cargo type). 3. Set of output cargo types. 4. Number of output entries.
getCargoTypesForStockList(stationEntity : Engine.Entity) : {CargoTypeId : CargoUtil.StockProperties} base/tealdef/gui/main/cargo_util.d.tl:144
Call as cargo_util.getCargoTypesForStockList
Notes
Returns input, output and booster properties per cargo type of a stock list.
| Parameter | Type | Description |
|---|---|---|
stationEntity |
Engine.Entity |
Stock list entity (the parameter name is misleading). |
Returns {CargoTypeId : CargoUtil.StockProperties}
Used in the base game: 5 times in 5 files
base/content/gui/gui/entity_window/entity_window_hud.tl:43
base/content/gui/gui/entity_window/town_building/town_building.tl:264
base/content/gui/gui/entity_window/perk/perk.tl:83
base/content/gui/gui/entity_window/industry/industry.tl:254
base/content/game_mechanics/game_mechanics/emission/pollution_cleanup_facility_hud.script.tl:60
getVehicleUnsetCapacities(vehicleEntity : Engine.Entity) : CargoUtil.VehicleUnsetCapacities base/tealdef/gui/main/cargo_util.d.tl:146
Call as cargo_util.getVehicleUnsetCapacities
Notes
Returns the capacities of a vehicle whose cargo type is not decided yet, split into single-type and multi-type capacities.
Returns CargoUtil.VehicleUnsetCapacities
Details
Only cargo types produced in the current game are considered. LocationCargoList uses
this to show empty vehicles in entity windows.
Used in the base game: 3 times in 3 files
base/content/gui/gui/main/cargo_react_util.tl:395
base/content/gui/gui/statistics/statistics_react_util.tl:228
base/content/gui/gui/statistics/statistic_vehicles.tl:70
getCargoFlowCount(entityFrom : Engine.Entity, entityTo : Engine.Entity, cargoType : CargoTypeId, toIsTown : boolean) : integer base/tealdef/gui/main/cargo_util.d.tl:154
Call as cargo_util.getCargoFlowCount
Notes
Returns how many items of a cargo type were transported per year from one entity to another.
| Parameter | Type | Description |
|---|---|---|
entityFrom |
Engine.Entity |
Source entity. |
entityTo |
Engine.Entity |
Target entity. |
cargoType |
CargoTypeId |
Cargo type id. |
toIsTown |
boolean |
If true, the log is read on entityTo instead of entityFrom. |
Returns integer: Items per year from api.engine.util.stock.getCargoLogPerYearForTarget(..., "itemsTransported", cargoType).
Used in the base game: 6 times in 2 files
base/content/gui/gui/entity_window/industry/industry_eow.script.tl:319
base/content/gui/gui/entity_window/industry/industry.tl:211
CargoUtil.StockConfig¶
record base/tealdef/gui/main/cargo_util.d.tl:8
record StockConfig
Notes
One group of stocks of a stock list, as returned by calculateStockConfigs.
Used in the base game: 36 times in 4 files
base/content/gui/gui/main/hud_icon_toolbox.tl:51
base/content/gui/gui/main/cargo_util.tl:30
sortByType : boolean, showEmpty : boolean, groupStocks : boolean, producedOnly : boolean) : {CargoUtil.StockConfig}, integer, boolean
base/content/gui/gui/statistics/statistic_warehouses.tl:28
local compareStockConfigs = function(a : CargoUtil.StockConfig, b : CargoUtil.StockConfig) : integer
base/content/gui/gui/entity_window/entity_window_util.tl:246
Fields
| Name | Type | Description |
|---|---|---|
ids |
{StockId} |
Stock ids (0-based) in this group. |
stored |
integer |
Number of cargo items stored in the group. |
capacity |
integer |
Sum of the capacities of the stocks in the group. |
cargoTypesSorted |
{CargoTypeId} |
Cargo types the group accepts. |
allCargoTypes |
boolean |
true if the group accepts all cargo types but one (#cargoTypesSorted == getCargoTypesCount(false) - 1). |
tendency |
integer |
Change of the stock per year. |
stockType |
StockListType |
Type of the stocks in the group (input, output or storage). |
quality |
integer |
Average cargo quality in percent (0-100). Only set when calculateQuality was requested and the group holds cargo. |
numSpoiled |
integer |
Number of spoiled (bad quality) cargo items. Only counted when calculateQuality was requested. |
canPinCargoType |
boolean |
true if the group is a storage stock with cargo type filters for which a single cargo type can be pinned. |
pinnedCargoType |
boolean |
true if the stocks have a pinned cargo type (stock.cargoType >= 0). nil when not determined. |
CargoUtil.StockCargoCount¶
record base/tealdef/gui/main/cargo_util.d.tl:25
record StockCargoCount
Notes
Amount of one cargo type in a stock list, as returned by calculateStockCargoCount.
Used in the base game: 8 times in 2 files
base/content/gui/gui/main/cargo_util.tl:207
cargo_util.calculateStockCargoCount = function(entity : Engine.Entity, sortByCargoType? : boolean, stockIds? : {StockId}, calculateQuality? : boolean) : {CargoU
base/content/gui/gui/statistics/statistic_warehouses.tl:379
Fields
| Name | Type | Description |
|---|---|---|
cargoType |
CargoTypeId |
Cargo type id. |
count |
integer |
Number of items of this cargo type in the counted stocks. |
spoiledCount |
integer |
Number of spoiled items. Only set when quality was requested. |
tendency |
integer |
Trend of the stock from -3 (strongly falling) to 3 (strongly rising). |
quality |
number |
Average quality of this cargo type in the whole stock list. Only set when quality was requested. |
CargoUtil.VehicleCargo¶
record base/tealdef/gui/main/cargo_util.d.tl:39
record VehicleCargo
Notes
Capacity and load of one cargo type summed over one or more vehicles.
Used in the base game: 10 times in 4 files
base/content/gui/gui/line_vehicle_mgmt/manager_window.tl:2556
base/content/gui/gui/main/cargo_util.tl:283
local calculateSortedVehicleCargoInfo = function(vehicleEntities : {Engine.Entity}, calculateQuality? : boolean, calculateFill? : boolean) : {CargoUtil.VehicleC
base/content/gui/gui/statistics/statistic_lines.tl:333
base/content/gui/gui/statistics/statistic_vehicles.tl:453
Fields
| Name | Type | Description |
|---|---|---|
cargoType |
CargoTypeId |
Cargo type id. |
capacity |
integer |
Total capacity for this cargo type over all vehicles. |
vehicleEntities |
{Engine.Entity} |
Vehicles that have capacity for this cargo type. |
fill |
integer |
Number of loaded items. Only filled for the compare-value functions. |
hasGoodCargo |
boolean |
true if a vehicle carries items of this type that are not spoiled. Only set with calculateQuality. |
hasBadCargo |
boolean |
true if a vehicle carries spoiled items of this type (never set for passengers). Only set with calculateQuality. |
CargoUtil.CargoListSortOrder¶
enum base/tealdef/gui/main/cargo_util.d.tl:58
enum CargoListSortOrder
Notes
Sort order of getSortedProducedCargoTypes. Ties are sorted by cargo type id.
Used in the base game: 2 times in 2 files
base/content/gui/gui/main/cargo_util.tl:843
base/content/gui/gui/entity_window/entity_window_util.tl:2204
| Value | Description |
|---|---|
"CAPACITY" |
Sort by capacity, ascending. |
"COUNT" |
Sort by the number of items, ascending. |
"ID" |
Sort by cargo type id. |
CargoUtil.CargoLocationParams¶
record base/tealdef/gui/main/cargo_util.d.tl:64
record CargoLocationParams
Notes
Where to collect cargo for getSortedProducedCargoTypes and getCargoTypeInfo. Set one or more of the entity fields; the results of all set locations are added up.
Used in the base game: 11 times in 6 files
base/content/gui/gui/line_vehicle_mgmt/line_react_util.tl:684
base/content/gui/gui/main/cargo_util.tl:584
local getCargoTypeInfoForCargoStockList = function(result : CargoUtil.CargoTypeInfo, cargoTypeId : CargoTypeId, locationParams : CargoUtil.CargoLocationParams)
base/content/gui/gui/statistics/statistic_lines.tl:62
base/content/gui/gui/statistics/statistics_react_util.tl:229
base/content/gui/gui/statistics/statistic_vehicles.tl:72
base/content/gui/gui/entity_window/entity_window_util.tl:2199
Fields
| Name | Type | Description |
|---|---|---|
vehicleEntity |
Engine.Entity |
Vehicle whose load and capacity are counted. |
stockListOwnerEntity |
Engine.Entity |
Industry, warehouse or town building whose stock list is counted (see getStockListEntityFromOwner). |
lineEntity |
Engine.Entity |
Line whose capacity usage is counted. |
stopIndex1 |
integer |
|
getTendency |
boolean |
If true, getCargoTypeInfo computes the stock tendency (only for stockListOwnerEntity). |
showEmpty |
boolean |
If true, also lists cargo types with no items. |
extraCapacity |
{CargoTypeId : integer} |
Capacity added per cargo type on top of the counted locations. |
CargoUtil.CargoStopParams¶
record base/tealdef/gui/main/cargo_util.d.tl:78
record CargoStopParams
Notes
Line stop for getConfiguredStopCargoTypes.
Used in the base game: 2 times in 2 files
base/content/gui/gui/line_vehicle_mgmt/line_react_util.tl:675
base/content/gui/gui/main/cargo_util.tl:820
Fields
| Name | Type | Description |
|---|---|---|
lineEntity |
Engine.Entity |
Line entity. |
stopIndex1 |
integer |
1-based index of the stop in Line.stops. |
getTendency |
boolean |
|
showEmpty |
boolean |
CargoUtil.CargoTypeInfo¶
record base/tealdef/gui/main/cargo_util.d.tl:86
record CargoTypeInfo
Notes
Amount, capacity and quality of one cargo type at a location, as returned by getCargoTypeInfo.
Used in the base game: 16 times in 4 files
base/content/gui/gui/main/cargo_react_util.tl:104
local makeCargoTypeIcons = function(params : CargoUtil.CargoTypeInfo, mode : GuiReactUtil.LabelMode, shippingState : GuiReactUtil.ShippingState, showLoadingIndi
base/content/gui/gui/main/cargo_util.tl:584
local getCargoTypeInfoForCargoStockList = function(result : CargoUtil.CargoTypeInfo, cargoTypeId : CargoTypeId, locationParams : CargoUtil.CargoLocationParams)
base/content/gui/gui/statistics/statistics_react_util.tl:194
statistics_react_util.calculateCargoColumnData = function(cargoTypeInfos : {cargo_util.CargoTypeInfo}) : StatisticsReactUtil.CargoColumnData
base/content/gui/gui/entity_window/entity_window_util.tl:2212
Fields
| Name | Type | Description |
|---|---|---|
cargoType |
CargoTypeId |
Cargo type id. -1 for an entry that stands for several cargo types (see cargoTypes). |
cargoTypes |
{CargoTypeId} |
Cargo types that share one capacity. Only set by getVehicleUnsetCapacities. |
capacity |
integer |
Capacity for this cargo type. |
count |
integer |
Number of items. |
tendency |
integer |
Stock trend from -3 to 3 (see StockCargoCount.tendency). Only set with getTendency. |
spoiledCount |
integer |
Number of spoiled items (or unhappy passengers). |
averageQuality |
number |
Average quality (0-1) of the items; for passengers their happiness. |
loadSpeedModifiers |
Engine.Component.TransportVehicle.LoadSpeedModifiers |
Load speed modifiers of the vehicle for this cargo type. Only set while the vehicle is at a terminal. |
loadState |
Engine.Component.TransportVehicle.LoadState |
Loading state of the vehicle. Only set while the vehicle is at a terminal. |
gameSpeed |
number |
Current game speed-up factor (GameSpeed.speedup). Set for vehicles; used for the loading animation speed. |
CargoUtil.VehicleUnsetCapacities¶
record base/tealdef/gui/main/cargo_util.d.tl:99
record VehicleUnsetCapacities
Notes
Capacities of a vehicle that are not bound to a cargo type yet, as returned by getVehicleUnsetCapacities.
Used in the base game: 1 time in 1 file
base/content/gui/gui/main/cargo_util.tl:941
Fields
| Name | Type | Description |
|---|---|---|
multiTypes |
{CargoUtil.CargoTypeInfo} |
Capacities that can take one of several cargo types, one CargoTypeInfo each with cargoType = -1 and the possible types in cargoTypes. |
singleCapacities |
{CargoTypeId : integer} |
Capacities that can take only one cargo type, by cargo type id. |
CargoUtil.StockProperties¶
record base/tealdef/gui/main/cargo_util.d.tl:139
record StockProperties
Notes
How a stock list uses a cargo type, as returned by getCargoTypesForStockList.
Used in the base game: 21 times in 10 files
base/content/gui/gui/main/cargo_util.tl:471
cargo_util.getCargoTypesForStockList = function(stockListEntity : Engine.Entity) : {CargoTypeId : CargoUtil.StockProperties}
base/content/gui/gui/entity_window/entity_window_hud.tl:23
local function isProducerMatchingConsumer(producer : {CargoTypeId : CargoUtil.StockProperties}, consumer : {CargoTypeId : CargoUtil.StockProperties}, bidirectio
base/content/gui/gui/entity_window/town/town.tl:828
base/content/gui/gui/entity_window/town_building/town_building.tl:249
base/content/game_mechanics/game_mechanics/emission/pollution_cleanup_facility_hud.script.tl:49
base/content/game_mechanics/game_mechanics/subventions/deliver_cargo/deliver_cargo.script.tl:273
… and 4 more files.
Fields
CargoUtil.CargoFlowData¶
record base/tealdef/gui/main/cargo_util.d.tl:148
record CargoFlowData
Notes
One supplier or consumer of a cargo flow, as built by the industry and town entity windows.
Used in the base game: 5 times in 2 files
base/content/gui/gui/entity_window/town/town.tl:865
base/content/gui/gui/entity_window/industry/industry.tl:205
Fields
| Name | Type | Description |
|---|---|---|
position |
Vec3f |
Position of the supplier or consumer entity. |
cargoType |
CargoTypeId |
Cargo type of the flow. |
cargoCount |
integer |
Items transported per year (from getCargoFlowCount). |