vehicle_react_util¶
Source: base/tealdef/gui/line_vehicle_mgmt/vehicle_react_util.d.tl
Notes
GUI recipes for vehicles (icons, condition, balance) and HandleVehicleChanges, which turns store results into buy, replace and sell commands.
VehicleReactUtil¶
record global base/tealdef/gui/line_vehicle_mgmt/vehicle_react_util.d.tl:3
global record VehicleReactUtil
Load: local vehicle_react_util = ug_require "/gui/line_vehicle_mgmt/vehicle_react_util.tl"
Notes
GUI recipes for vehicles and the helper that applies vehicle store results.
Fields
| Name | Type | Description |
|---|---|---|
ConditionTextView |
Recipe<Engine.Entity> |
Recipe taking a vehicle entity; shows its condition text (VehicleUtil.getConditionText) as a button that opens the vehicle's entity window. Updated every step. |
ConditionIcon |
Recipe<Engine.Entity> |
Recipe taking a vehicle entity; shows its condition icon with the condition text as tooltip. Clicking selects the vehicle. |
VehicleImage |
Recipe<VehicleIconData> |
Recipe drawing one vehicle part icon; tinted with color through cblendFileName when both are set. |
VehicleWidget |
Recipe<VehicleWidgetParams> |
Recipe showing the icons of one or more vehicles in a horizontal scroll area, grouping equal compositions and equal consecutive parts with counters. used 6× in the base game |
VehicleBalance |
Recipe<VehicleBalanceParams> |
Recipe showing a vehicle's balance over the last game year (api.engine.util.finance.calculateBalance), styled negative or positive. used 2× in the base game |
Functions
makeVehicleIconData(VehicleImageParams) : VehicleIconData base/tealdef/gui/line_vehicle_mgmt/vehicle_react_util.d.tl:38
Call as vehicle_react_util.makeVehicleIconData
Notes
Builds icon data for one part of a vehicle from its model description.
Returns VehicleIconData: Icon data for VehicleImage.
getVehicleIconType(Engine.Entity) : VehicleIconType base/tealdef/gui/line_vehicle_mgmt/vehicle_react_util.d.tl:43
Call as vehicle_react_util.getVehicleIconType
Notes
Picks the VehicleIconType of a vehicle from its carrier, transport modes, engine type (rail) and helicopter flag (air).
Returns VehicleIconType: The icon type, or nil for unknown carriers.
getVehicleIconPathBig(Engine.Entity) : string base/tealdef/gui/line_vehicle_mgmt/vehicle_react_util.d.tl:44
Call as vehicle_react_util.getVehicleIconPathBig
Notes
Path of the large HUD vehicle icon (::/gui/hud/icons/vehicle_*.tga) for a vehicle, based on getVehicleIconType.
Returns string: Icon path, or nil.
HandleVehicleChanges(changes : {VehicleReactUtil.VehicleChange}, protectedEntities : {Engine.Entity : GameContext.Filters.ProtectionConfig | boolean}, getLineAndDepot : function(vehicleEntity : Engine.Entity) : {Engine.Entity, Engine.Entity}, getFirstStopToSendTo : function(vehicleToSendToLine : Engine.Entity, lineToSendTo : Engine.Entity) : integer, onBuy : function(resultEntities : {{Engine.Entity, Engine.Revision}}), onFail? : function(reason : string)) base/tealdef/gui/line_vehicle_mgmt/vehicle_react_util.d.tl:46
Call as vehicle_react_util.HandleVehicleChanges
Notes
Sends the commands for a list of vehicle store changes - buy new vehicles, replace vehicle configurations, or sell vehicles.
| Parameter | Type | Description |
|---|---|---|
changes |
{VehicleReactUtil.VehicleChange} |
Changes to apply. Parts with purchaseTime <= 0 get the current game time; auto load config is switched on for all compartments. |
protectedEntities |
{Engine.Entity : GameContext.Filters.ProtectionConfig | boolean} |
Vehicles that must not be sold (from gameCtx.filters); may be nil. |
getLineAndDepot |
function(vehicleEntity : Engine.Entity) : {Engine.Entity, Engine.Entity} |
For new vehicles (negative vehicleEntity) returns {line, depot}; the vehicle is bought in the depot and, if the line is >= 0, sent to it. |
getFirstStopToSendTo |
function(vehicleToSendToLine : Engine.Entity, lineToSendTo : Engine.Entity) : integer |
Returns the stop index a newly bought vehicle is sent to on its line; 0 if nil. |
onBuy |
function(resultEntities : {{Engine.Entity, Engine.Revision}}) |
Called with {{entity, revision}} of each bought vehicle. |
onFail? |
function(reason : string) |
Called with a translated reason if buying fails or no depot is found. |
Details
Uses api.cmd.makeVehicleBuyCmd, makeVehicleSetLineCmd, makeVehicleReplaceCmd
and makeVehicleSellCmd. Replacing a vehicle spawns a happy emote HUD image above it
unless event icons are hidden in the HUD filter.
VehicleReactUtil.VehicleImageParams¶
record base/tealdef/gui/line_vehicle_mgmt/vehicle_react_util.d.tl:5
record VehicleImageParams
Notes
Selects one part of a vehicle for makeVehicleIconData.
Used in the base game: 1 time in 1 file
base/content/gui/gui/line_vehicle_mgmt/vehicle_react_util.tl:15
Fields
| Name | Type | Description |
|---|---|---|
vehicleEntity |
Engine.Entity |
Vehicle entity (with a TRANSPORT_VEHICLE component). |
vehicleIndex |
integer |
One-based index into transportVehicleConfig.vehicles (the part, e.g. a wagon). |
VehicleReactUtil.VehicleIconData¶
record base/tealdef/gui/line_vehicle_mgmt/vehicle_react_util.d.tl:10
record VehicleIconData
Notes
Data for drawing one vehicle part icon with VehicleImage.
Used in the base game: 9 times in 1 file
base/content/gui/gui/line_vehicle_mgmt/vehicle_react_util.tl:15
Fields
| Name | Type | Description |
|---|---|---|
fileName |
string |
Icon image path (the model's description.icon20). |
cblendFileName |
string |
Colour-blend mask (description.icon20cblend); with color set the icon is tinted through this mask. |
name |
string |
Model name, used as tooltip. |
flippedHorizontally |
boolean |
True if the part is reversed in the consist. |
color |
Vec3f |
Part colour; nil if the part has no custom colour (colour x < 0). |
tooltipOverride |
string |
Tooltip used instead of name. |
VehicleReactUtil.VehicleWidgetParams¶
record base/tealdef/gui/line_vehicle_mgmt/vehicle_react_util.d.tl:19
record VehicleWidgetParams
Notes
Parameters of VehicleWidget.
Used in the base game: 1 time in 1 file
base/content/gui/gui/line_vehicle_mgmt/vehicle_react_util.tl:118
Fields
| Name | Type | Description |
|---|---|---|
vehicleEntities |
{Engine.Entity} |
Vehicles to show; vehicles with the same composition are grouped with an Nx counter. |
class |
string |
Extra style classes. |
blinking |
boolean |
Adds the blinking style class to the button (only with onClick). |
tooltipOverride |
string |
Tooltip for all part icons instead of the model names. |
Functions
onClick() base/tealdef/gui/line_vehicle_mgmt/vehicle_react_util.d.tl:21
Notes
If set, the widget is a button calling this function.
VehicleReactUtil.MaintenanceSelectorParams¶
record base/tealdef/gui/line_vehicle_mgmt/vehicle_react_util.d.tl:27
record MaintenanceSelectorParams
Notes
Declared parameter record; not used by base-game code.
Fields
| Name | Type | Description |
|---|---|---|
vehicles |
{EntityUtil.EntityAndRevision} |
|
onlySlider |
boolean |
Functions
onClose() base/tealdef/gui/line_vehicle_mgmt/vehicle_react_util.d.tl:28
No description in the game files yet.
VehicleReactUtil.VehicleChange¶
record base/tealdef/gui/line_vehicle_mgmt/vehicle_react_util.d.tl:33
record VehicleChange
Notes
One change produced by the vehicle store and applied by HandleVehicleChanges.
Used in the base game: 8 times in 4 files
base/content/mission/mission/tasks/vehicle_util/replace_vehicles.tl:8
base/content/gui/gui/line_vehicle_mgmt/vehicle_store_window.tl:3433
base/content/gui/gui/line_vehicle_mgmt/vehicle_react_util.tl:320
base/content/gui/gui/line_vehicle_mgmt/manager_window.tl:8497
Fields
| Name | Type | Description |
|---|---|---|
vehicleEntity |
Engine.Entity |
Vehicle to replace or sell; a negative value means a new vehicle is bought. |
config |
TransportVehicleConfig |
New vehicle configuration; an empty vehicles list sells the vehicle. |
VehicleReactUtil.VehicleBalanceParams¶
record base/tealdef/gui/line_vehicle_mgmt/vehicle_react_util.d.tl:58
record VehicleBalanceParams
Notes
Parameters of VehicleBalance.
Used in the base game: 1 time in 1 file
base/content/gui/gui/line_vehicle_mgmt/vehicle_react_util.tl:414
Fields
| Name | Type | Description |
|---|---|---|
entity |
Engine.Entity |
Vehicle whose balance is shown. |
stepTimer |
boolean |
If true, refreshes on a step timer instead of every step. |