vehicle_util¶
Source: base/tealdef/gui/line_vehicle_mgmt/vehicle_util.d.tl
Notes
Small helpers for vehicles and depots - lifespan and age, condition text and icons, carrier of a depot, vehicle type, capacity checks and the year-dependent value ranges used to scale the store's progress bars.
VehicleUtil¶
record global base/tealdef/gui/line_vehicle_mgmt/vehicle_util.d.tl:3
global record VehicleUtil
Load: local vehicle_util = ug_require "/gui/line_vehicle_mgmt/vehicle_util.tl"
Notes
Small helpers for vehicles and depots.
Fields
Functions
makePart(modelId : integer, forward : boolean, color : Vec3f) : TransportVehiclePart base/tealdef/gui/line_vehicle_mgmt/vehicle_util.d.tl:11
Call as vehicle_util.makePart
Notes
Creates a TransportVehiclePart for a model, with load config 0 for every compartment.
| Parameter | Type | Description |
|---|---|---|
modelId |
integer |
Model id of a vehicle. |
forward |
boolean |
False to reverse the part. |
color |
Vec3f |
Optional part colour. |
Returns TransportVehiclePart
Used in the base game: 5 times in 2 files
base/content/mission/mission/tasks/vehicle_util/replace_vehicles.tl:41
base/content/gui/gui/line_vehicle_mgmt/vehicle_store_window.tl:4042
getLifespan(integer) : integer base/tealdef/gui/line_vehicle_mgmt/vehicle_util.d.tl:12
Call as vehicle_util.getLifespan
Notes
Lifespan of a vehicle model.
Returns integer: maintenance.lifespan times 1000; compared with part purchase times in game time.
getMinPurchaseTimeAndLifespan(Engine.Component.TransportVehicle) : {integer, integer} base/tealdef/gui/line_vehicle_mgmt/vehicle_util.d.tl:13
Call as vehicle_util.getMinPurchaseTimeAndLifespan
Notes
Purchase time and lifespan of the oldest part of a transport vehicle (shortest lifespan on ties).
Returns {integer, integer}: {purchaseTime, lifespan}.
getDepotCarriers(Engine.Entity) : {Carrier} base/tealdef/gui/line_vehicle_mgmt/vehicle_util.d.tl:14
Call as vehicle_util.getDepotCarriers
Notes
Carriers of the transport modes enabled in a vehicle depot.
Returns {Carrier}
getDepotCarrier(Engine.Entity) : Carrier base/tealdef/gui/line_vehicle_mgmt/vehicle_util.d.tl:15
Call as vehicle_util.getDepotCarrier
Notes
The single carrier of a vehicle depot.
Returns Carrier: The carrier, or nil (with a warning in the log) if the depot has none or several.
getDepotTransportModes(Engine.Entity) : {TransportMode : boolean} base/tealdef/gui/line_vehicle_mgmt/vehicle_util.d.tl:16
Call as vehicle_util.getDepotTransportModes
Notes
Transport modes of a vehicle depot.
Returns {TransportMode : boolean}: The depot's transportModes, or an empty table if the depot has no in or out nodes.
Used in the base game: 3 times in 3 files
base/content/gui/gui/line_vehicle_mgmt/manager_window.tl:7142
base/content/gui/gui/line_vehicle_mgmt/line_react_util.tl:425
base/content/game_mechanics/game_mechanics/notifications/types/availability.script.tl:99
getVehicleTypeFromModel(model : Model) : VehicleType base/tealdef/gui/line_vehicle_mgmt/vehicle_util.d.tl:28
Call as vehicle_util.getVehicleTypeFromModel
Notes
Vehicle type of a model from its transportVehicle.transportModes; Train if nothing matches.
Returns VehicleType
getVehicleTypeFromEntity(ent : Engine.Entity) : VehicleType base/tealdef/gui/line_vehicle_mgmt/vehicle_util.d.tl:29
Call as vehicle_util.getVehicleTypeFromEntity
Notes
Vehicle type of a vehicle entity from its carrier (bus vs. truck from the transport modes, helicopter vs. airplane from the first part's model).
Returns VehicleType
Used in the base game: 2 times in 2 files
base/content/game_mechanics/game_mechanics/notifications/types/vehicle_warning.sim.script.tl:14
base/content/game_mechanics/game_mechanics/notifications/types/vehiclecondition.sim.script.tl:14
getConditionText(number) : string base/tealdef/gui/line_vehicle_mgmt/vehicle_util.d.tl:32
Call as vehicle_util.getConditionText
Notes
Condition name for a maintenance state from 0 to 1 (split into five equal steps).
Returns string
Used in the base game: 6 times in 4 files
base/content/gui/gui/line_vehicle_mgmt/vehicle_react_util.tl:42
base/content/gui/gui/statistics/statistic_vehicles.tl:228
base/content/gui/gui/entity_window/entity_window_util.tl:1996
base/content/gui/gui/entity_window/vehicle/vehicle_eow.script.tl:1115
getConditionIcon(number) : string base/tealdef/gui/line_vehicle_mgmt/vehicle_util.d.tl:33
Call as vehicle_util.getConditionIcon
Notes
Condition icon path (::/gui/line_vehicle_mgmt/icons/condition_*.tga) for a maintenance state from 0 to 1.
Returns string
getNoise01(emissions : number, carrier : Carrier) : number base/tealdef/gui/line_vehicle_mgmt/vehicle_util.d.tl:37
Call as vehicle_util.getNoise01
Notes
Maps a noise emission value to 0 to 1, by carrier (0 to 200 for rail, 0 to 300 for air, 0 to 100 otherwise).
Returns number
getPollution01(emissions : number, carrier : Carrier) : number base/tealdef/gui/line_vehicle_mgmt/vehicle_util.d.tl:38
Call as vehicle_util.getPollution01
Notes
Maps a pollution emission value to 0 to 1, by carrier (0 to 200 for rail, 0 to 300 for air, 0 to 100 otherwise).
Returns number
isAbleToLoadCargo(tv : Engine.Component.TransportVehicle) : boolean base/tealdef/gui/line_vehicle_mgmt/vehicle_util.d.tl:40
Call as vehicle_util.isAbleToLoadCargo
Notes
True if the transport vehicle has capacity for any cargo other than passengers.
Returns boolean
isAbleToLoadPassenger(tv : Engine.Component.TransportVehicle) : boolean base/tealdef/gui/line_vehicle_mgmt/vehicle_util.d.tl:41
Call as vehicle_util.isAbleToLoadPassenger
Notes
True if the transport vehicle has passenger capacity (any load config).
Returns boolean
getRanges(carrier : Carrier, onlyPassengers : boolean, year : integer) : Ranges base/tealdef/gui/line_vehicle_mgmt/vehicle_util.d.tl:57
Call as vehicle_util.getRanges
Notes
Value ranges for a carrier and game year.
| Parameter | Type | Description |
|---|---|---|
carrier |
Carrier |
Vehicle carrier. |
onlyPassengers |
boolean |
True for vehicles that carry only passengers. |
year |
integer |
Current game year. |
Returns Ranges
Used in the base game: 3 times in 3 files
base/content/gui/gui/line_vehicle_mgmt/vehicle_store_util.tl:425
base/content/gui/gui/entity_window/vehicle/vehicle_eow.script.tl:502
base/content/game_mechanics/game_mechanics/subventions/subvention_util.tl:487
getAvgMaintenanceState(Engine.Entity) : number, number base/tealdef/gui/line_vehicle_mgmt/vehicle_util.d.tl:59
Call as vehicle_util.getAvgMaintenanceState
Notes
Average maintenance state of all parts of a vehicle.
Returns number, number: Average state (1.0 if the vehicle has no parts) and average maintenance change.
Used in the base game: 11 times in 6 files
base/content/gui/gui/line_vehicle_mgmt/vehicle_react_util.tl:41
base/content/gui/gui/statistics/statistic_vehicles.tl:218
base/content/gui/gui/entity_window/entity_window_util.tl:1987
base/content/gui/gui/entity_window/maintenance_station/maintenance_station_eow.script.tl:209
base/content/gui/gui/entity_window/vehicle/vehicle_eow.script.tl:686
mods/release/urbangames_campaign_mission_03/content/mission/mission/tasks/fatal_maintenance/fatal_maintenance.tl:42
getAge(Engine.Entity) : AgeInfo base/tealdef/gui/line_vehicle_mgmt/vehicle_util.d.tl:68
Call as vehicle_util.getAge
Notes
Age information of a vehicle, based on its oldest part and the current game time.
Returns AgeInfo
GetVehicleModelIds(Engine.Entity) : {integer} base/tealdef/gui/line_vehicle_mgmt/vehicle_util.d.tl:70
Call as vehicle_util.GetVehicleModelIds
Notes
Model ids of all parts of a vehicle, in consist order.
Returns {integer}
Used in the base game: 4 times in 4 files
base/content/gui/gui/line_vehicle_mgmt/vehicle_list_react_util.tl:560
base/content/gui/gui/statistics/statistic_depots.tl:135
base/content/gui/gui/statistics/statistic_lines.tl:268
base/content/gui/gui/statistics/statistic_vehicles.tl:361
getPowerRatingTextAndToolTip(weight : number, power : number, tractiveEffort : number, topSpeed : number, rollingFriction : number) : {string, string, number} base/tealdef/gui/line_vehicle_mgmt/vehicle_util.d.tl:72
Call as vehicle_util.getPowerRatingTextAndToolTip
Notes
Power rating of a land vehicle (Poor, Mediocre, Good, Excellent) with a tooltip listing the top speed reachable on flat, medium and high slopes.
| Parameter | Type | Description |
|---|---|---|
weight |
number |
Vehicle weight. |
power |
number |
Engine power. |
tractiveEffort |
number |
Tractive effort. |
topSpeed |
number |
Top speed. |
rollingFriction |
number |
Rolling friction. |
Returns {string, string, number}: {ratingText, tooltip, rating01}, or nil if the acceleration integration fails.
isCurrentlyAbleToHoldPassengers(vehicleEntity : Engine.Entity) : boolean base/tealdef/gui/line_vehicle_mgmt/vehicle_util.d.tl:75
Call as vehicle_util.isCurrentlyAbleToHoldPassengers
Notes
True if the vehicle's current configuration has passenger capacity.
Returns boolean
Used in the base game: 2 times in 2 files
base/content/gui/gui/layers/layer_passenger_flow.tl:52
base/content/gui/gui/layers/layer_public_transport.tl:97
VehicleUtil.AgeInfo¶
record base/tealdef/gui/line_vehicle_mgmt/vehicle_util.d.tl:4
record AgeInfo
Notes
Age information of a vehicle, from getAge.
Used in the base game: 2 times in 2 files
base/content/gui/gui/line_vehicle_mgmt/vehicle_util.tl:297
base/content/gui/gui/statistics/statistic_vehicles.tl:236
Fields
VehicleUtil.VehicleType¶
enum base/tealdef/gui/line_vehicle_mgmt/vehicle_util.d.tl:18
enum VehicleType
Notes
Coarse vehicle type, derived from transport modes or carrier.
Used in the base game: 11 times in 4 files
base/content/gui/gui/line_vehicle_mgmt/vehicle_util.tl:84
base/content/game_mechanics/game_mechanics/notifications/types/vehicle_warning.script.tl:81
base/content/game_mechanics/game_mechanics/notifications/types/vehiclecondition.script.tl:23
base/content/game_mechanics/game_mechanics/notifications/types/availability.script.tl:115
| Value | Description |
|---|---|
"Train" |
Train (also the fallback). |
"Tram" |
Tram. |
"Bus" |
Bus. |
"Truck" |
Truck. |
"Ship" |
Ship (large or small). |
"Airplane" |
Aircraft (large or small). |
"Helicopter" |
Helicopter. |
VehicleUtil.Ranges¶
record base/tealdef/gui/line_vehicle_mgmt/vehicle_util.d.tl:43
record Ranges
Notes
Value ranges used by the vehicle store and vehicle window to scale property bars, from getRanges.
Details
The base game keeps a small table per carrier with entries for certain years (e.g. rail 1900, 1921, 1941, 1981); the last entry whose year is reached wins.
Used in the base game: 7 times in 4 files
base/content/gui/gui/line_vehicle_mgmt/vehicle_store_window.tl:480
base/content/gui/gui/line_vehicle_mgmt/vehicle_util.tl:210
base/content/gui/gui/line_vehicle_mgmt/vehicle_store_util.tl:412
base/content/gui/gui/entity_window/vehicle/vehicle_eow.script.tl:420
Fields
VehicleUtil.Emissions¶
record base/tealdef/gui/line_vehicle_mgmt/vehicle_util.d.tl:61
record Emissions
Notes
Declared record; not used by base-game code.
Fields
| Name | Type | Description |
|---|---|---|
score |
integer |
|
currentBase |
integer |
|
currentExtra |
integer |
|
conditionIndex |
integer |