Skip to content

construction_desc_react_util

Source: base/tealdef/gui/construction/construction_desc_react_util.d.tl

Notes

Helper module for the info panel of construction menu entries (::/gui/construction/construction_desc_react_util.tl): collects the numbers (cost, maintenance, emissions, effects, permits) from a definition and its metadata, formats them for display, and has the default HUD icon configurations used by configureHudIconsScript scripts.

ConstructionDescReactUtil

record global base/tealdef/gui/construction/construction_desc_react_util.d.tl:3

global record ConstructionDescReactUtil

Load: local construction_desc_react_util = ug_require "::/gui/construction/construction_desc_react_util.tl"

Notes

Helper module for the info panel of construction menu entries. Load it with ug_require "::/gui/construction/construction_desc_react_util.tl".

Fields

Name Type Description
ConstructionInfoNumberList Recipe<ConstructionInfoNumberListParam> Recipe that shows one line of formatted numbers (icon and text per item). used 2× in the base game

Functions

getAttributesFromConstructionResult(updateFnResult1 : ConstructionResult) : {string : {number, number, {string}}} base/tealdef/gui/construction/construction_desc_react_util.d.tl:65

Call as construction_desc_react_util.getAttributesFromConstructionResult

Notes

Extracts the info panel attributes from the result of a construction's update function.

Returns {string : {number, number, {string}}}: Attributes by key (cost, maintenanceCost, noise, pollution, radius, pollutionRadius, capacityPassenger, comfortFactor, maintenanceCapacity, ...), each {min, max} with max = -1 for a single value.

Details

The maintenance cost is scaled by the base config's infrastructureMaintenanceScale.

collectNumbers(metadata : ConstructionDescMetadata, definition : ConstructionDefinition, cache : ConstructionReactUtil.ItemDisableCache, attributes : {string : {number, number, {string}}}) : Numbers base/tealdef/gui/construction/construction_desc_react_util.d.tl:68

Call as construction_desc_react_util.collectNumbers

cache may be nil. Is only required for getting the number available permits.

Returns Numbers

Used in the base game: 3 times in 2 files

base/content/gui/gui/entity_window/perk/perk_eow.script.tl:43

numbers = construction_desc_react_util.collectNumbers(desc.metadata, nil, nil, nil)
base/content/game_mechanics/game_mechanics/company/company_react_util.tl:70
newPerk.numbers = construction_desc_react_util.collectNumbers(perk.metadata, perk, nil, nil)

formatNumbers(numbers : Numbers) : {{FormatNumberDesc}} base/tealdef/gui/construction/construction_desc_react_util.d.tl:69

Call as construction_desc_react_util.formatNumbers

Notes

Formats collected numbers for the info panel.

Returns {{FormatNumberDesc}}: Lines of formatted numbers; each line is placed by the layoutType of its first item.

Used in the base game: 2 times in 2 files

base/content/gui/gui/entity_window/perk/perk_eow.script.tl:57

state.formattedNumbers = construction_desc_react_util.formatNumbers(numbers)
base/content/game_mechanics/game_mechanics/company/company.tl:125
and construction_desc_react_util.formatNumbers(currentPerk.numbers)

getDepotHudIconsConfig(capturedParams : ConstructionDescReactUtil.DepotHudIconsConfigParams) : ConstructionActionHudIcons base/tealdef/gui/construction/construction_desc_react_util.d.tl:86

Call as construction_desc_react_util.getDepotHudIconsConfig

Notes

HUD icons for placing a depot (stations, depots, signals for rail, and the maintenance station pool), filtered by carrier.

Returns ConstructionActionHudIcons

Used in the base game: 2 times in 2 files

base/content/gui/gui/construction/construction_desc_hud_icons.script.tl:8

return construction_desc_react_util.getDepotHudIconsConfig(capturedParams)
base/content/gui/gui/construction/tools/rail_electrification_tool.script.tl:22
hudIcons = construction_desc_react_util.getDepotHudIconsConfig{

getStationHudIconsConfig(capturedParams : ConstructionDescReactUtil.StationHudIconsConfigParams) : ConstructionActionHudIcons base/tealdef/gui/construction/construction_desc_react_util.d.tl:87

Call as construction_desc_react_util.getStationHudIconsConfig

Notes

HUD icons for placing a station (stations, towns, industries, plus signals or warehouses), with districts shown.

Returns ConstructionActionHudIcons

Used in the base game: 1 time in 1 file

base/content/gui/gui/construction/construction_desc_hud_icons.script.tl:5

return construction_desc_react_util.getStationHudIconsConfig(capturedParams)

getStreetBuilderHudIconsConfig() : ConstructionActionHudIcons base/tealdef/gui/construction/construction_desc_react_util.d.tl:88

Call as construction_desc_react_util.getStreetBuilderHudIconsConfig

Notes

HUD icons for the street builder (nodes, industries, towns, stations, road depots, warehouses).

Returns ConstructionActionHudIcons

Used in the base game: 1 time in 1 file

base/content/gui/gui/construction/construction_desc_hud_icons.script.tl:32

return construction_desc_react_util.getStreetBuilderHudIconsConfig()

getTrackBuilderHudIconsConfig() : ConstructionActionHudIcons base/tealdef/gui/construction/construction_desc_react_util.d.tl:89

Call as construction_desc_react_util.getTrackBuilderHudIconsConfig

Notes

HUD icons for the track builder (industries, towns, signals, stations, rail depots, warehouses).

Returns ConstructionActionHudIcons

Used in the base game: 1 time in 1 file

base/content/gui/gui/construction/construction_desc_hud_icons.script.tl:35

return construction_desc_react_util.getTrackBuilderHudIconsConfig()

getLandmarkConstructionHudIconsConfig() : ConstructionActionHudIcons base/tealdef/gui/construction/construction_desc_react_util.d.tl:90

Call as construction_desc_react_util.getLandmarkConstructionHudIconsConfig

Notes

HUD icons for placing a landmark (towns and landmark constructions, with showPerksAndTowns).

Returns ConstructionActionHudIcons

Used in the base game: 1 time in 1 file

base/content/gui/gui/construction/construction_desc_hud_icons.script.tl:38

return construction_desc_react_util.getLandmarkConstructionHudIconsConfig()

getDefaultHudIconsConfig() : ConstructionActionHudIcons base/tealdef/gui/construction/construction_desc_react_util.d.tl:91

Call as construction_desc_react_util.getDefaultHudIconsConfig

Notes

Default HUD icons (towns, with town borders).

Returns ConstructionActionHudIcons

Used in the base game: 1 time in 1 file

base/content/gui/gui/construction/construction_desc_hud_icons.script.tl:41

return construction_desc_react_util.getDefaultHudIconsConfig()

formatEffectPercentage(value : number) : string base/tealdef/gui/construction/construction_desc_react_util.d.tl:93

Call as construction_desc_react_util.formatEffectPercentage

Notes

Formats an effect factor as a percentage change (factor minus 1, for example 1.2 as +20 %).

Returns string

Used in the base game: 1 time in 1 file

base/content/game_mechanics/game_mechanics/towns/town_react_util.tl:1324

local percentageStr = construction_desc_react_util.formatEffectPercentage(effectModifier.value)

vehicleEffectMoreIsBetter(effectType : string) : boolean base/tealdef/gui/construction/construction_desc_react_util.d.tl:94

Call as construction_desc_react_util.vehicleEffectMoreIsBetter

Notes

Tells whether a higher value of a vehicle effect is an improvement.

Returns boolean: true for topSpeed and comfort, false for noise and pollution; logs an error and returns true for other types.

Used in the base game: 1 time in 1 file

base/content/game_mechanics/game_mechanics/towns/town_react_util.tl:1325

local isPositive = effectModifier.value > 1 == construction_desc_react_util.vehicleEffectMoreIsBetter(effect)

getVehicleEffectName(effect : string, carrier : string) : string base/tealdef/gui/construction/construction_desc_react_util.d.tl:95

Call as construction_desc_react_util.getVehicleEffectName

Notes

Returns the translated label of a vehicle effect for a carrier, for example "Train Top Speed".

Parameter Type Description
effect string Effect type: topSpeed, noise, pollution or comfort.
carrier string Carrier (ROAD, RAIL, AIR, WATER, TRAM); other values give the generic "Vehicle ..." label.

Returns string: The label, or nil for an unknown effect.

Used in the base game: 1 time in 1 file

base/content/game_mechanics/game_mechanics/towns/town_react_util.tl:1381

text = construction_desc_react_util.getVehicleEffectName(row.effect, row.carrier),

ConstructionDescReactUtil.CargoAndAmount

record base/tealdef/gui/construction/construction_desc_react_util.d.tl:4

record CargoAndAmount

Notes

A cargo type and amount (for example a landmark's resource requirement).

Used in the base game: 6 times in 2 files

base/content/gui/gui/construction/construction_desc_react_util.tl:425

local formatCargoCosts = function(cargoCosts : { ConstructionDescReactUtil.CargoAndAmount }) : { ConstructionDescReactUtil.FormatNumberDesc }
base/content/gui/gui/construction/construction.tl:3145
local formatCargoTypeSet = function(cargoTypeIds : { ConstructionDescReactUtil.CargoAndAmount }) : TreeNodeId

Fields

Name Type Description
cargoType integer Cargo type id.
amount integer Amount; -1 where only the cargo type matters.

ConstructionDescReactUtil.MinMax

record base/tealdef/gui/construction/construction_desc_react_util.d.tl:9

record MinMax

Notes

A value range for the info panel.

Used in the base game: 19 times in 1 file

base/content/gui/gui/construction/construction_desc_react_util.tl:23

local function getMinMaxPerKmFactor(minMax : ConstructionDescReactUtil.MinMax) : ConstructionDescReactUtil.MinMax

Fields

Name Type Description
min number Lower value (or the single value).
max number Upper value; -1 for cost values marks a single value.
range number Radius of a noise or pollution emission.

ConstructionDescReactUtil.Effect

record base/tealdef/gui/construction/construction_desc_react_util.d.tl:14

record Effect

Notes

An effect shown in the info panel.

Used in the base game: 5 times in 1 file

base/content/gui/gui/construction/construction_desc_react_util.tl:227

local getVehicleEffectFunction = function(effect : ConstructionDescReactUtil.Effect) : ConstructionDescReactUtil.FormatNumberDesc

Fields

Name Type Description
type string Effect type, for example topSpeed, noise, pollution, comfort, marketing, greenifyNoise or greenifyPollution.
value number Effect factor (1 is no change; shown as a percentage), or the duration in milliseconds for marketing.
carrier string Carrier the vehicle effect applies to (ROAD, RAIL, AIR, WATER, TRAM); other values give a generic vehicle label.

ConstructionDescReactUtil.Numbers

record base/tealdef/gui/construction/construction_desc_react_util.d.tl:19

record Numbers

Notes

Key numbers of a menu entry collected by collectNumbers and formatted by formatNumbers.

Used in the base game: 6 times in 3 files

base/content/gui/gui/construction/construction_desc_react_util.tl:279

local function formatPermitKey(numbers : ConstructionDescReactUtil.Numbers) : ConstructionDescReactUtil.FormatNumberDesc
base/content/gui/gui/construction/construction.tl:3508
numbers : ConstructionDescReactUtil.Numbers
base/content/gui/gui/entity_window/perk/perk_eow.script.tl:28
local numbers : ConstructionDescReactUtil.Numbers = {}

Fields

Name Type Description
companyRank MinMax
xpIncrease MinMax Town growth increase (from town growth metadata).
trafficRatingIncrease MinMax Traffic rating increase (from town growth metadata).
reputationRecoveryBoost MinMax Reputation recovery boost (from town growth metadata).
noise MinMax Noise emission; negative values are shown as noise reduction.
pollution MinMax Pollution emission; negative values are shown as pollution cleaning.
noiseModifier MinMax
pollutionModifier MinMax
maxSpeedModifier MinMax
speedLimit MinMax Top speed (from track description metadata or the speedLimit attribute).
numLanes MinMax Number of lanes (from track description metadata).
numAvailable integer Remaining uses of the company permit; needs the cache.
capacityPassenger MinMax Passenger capacity.
comfortFactor MinMax Comfort bonus.
effects {Effect} Effects such as vehicle speed, noise or pollution modifiers.
cost MinMax Construction cost in game currency.
maintenanceCost MinMax Maintenance cost in game currency per year.
maintenanceCapacity MinMax Maintenance capacity.
costPerKm boolean Shows costs and emissions per km or mile (from attributesCostPerKm).
cargoCosts {ConstructionDescReactUtil.CargoAndAmount} Cargo required to build (landmark requirements, scaled by the landmarkResources option).
depotCapacity MinMax
permitKey ResName Company permit key of the entry.
perkCategory CompanyMetadata.ConstructionDesc.PerkCategory Perk category of the entry.
cooldownInSeconds number Cooldown of the permit in seconds.

ConstructionDescReactUtil.LayoutType

enum base/tealdef/gui/construction/construction_desc_react_util.d.tl:47

enum LayoutType

Notes

Where a formatted number is placed in the info panel.

Used in the base game: 5 times in 1 file

base/content/gui/gui/construction/construction.tl:3188

local makeBelowInfoPictureLayout = function(textOnImage : { ConstructionDescReactUtil.LayoutType : {{ConstructionDescReactUtil.FormatNumberDesc}} }, disabled? :

Value Description
"TopLeft" Top left of the preview image (used for negative values such as emissions).
"TopRight" Top right of the preview image (used for positive values such as top speed).
"BottomLeft" Bottom left of the preview image (durations, cooldowns, remaining uses).
"BottomRight" Bottom right of the preview image.
"BelowImageLeft" Below the image, left, in the title font (cost, cargo costs).
"BelowImageRight" Below the image, right (maintenance cost).

ConstructionDescReactUtil.FormatNumberDesc

record base/tealdef/gui/construction/construction_desc_react_util.d.tl:56

record FormatNumberDesc

Notes

A formatted number for the info panel.

Used in the base game: 33 times in 4 files

base/content/gui/gui/construction/construction_desc_react_util.tl:70

local formatNumber : {{string, function(ConstructionDescReactUtil.MinMax) : ConstructionDescReactUtil.FormatNumberDesc }} = {
base/content/gui/gui/construction/construction.tl:3188
local makeBelowInfoPictureLayout = function(textOnImage : { ConstructionDescReactUtil.LayoutType : {{ConstructionDescReactUtil.FormatNumberDesc}} }, disabled? :
base/content/gui/gui/entity_window/perk/perk_eow.script.tl:22
formattedNumbers : {{ConstructionDescReactUtil.FormatNumberDesc}}
base/content/game_mechanics/game_mechanics/company/company.tl:124
local formattedNumbers : {{ConstructionDescReactUtil.FormatNumberDesc}} = (currentPerk and currentPerk.numbers)

Fields

Name Type Description
icon string Icon shown with the text.
text string Text to show.
singleLine boolean Puts the item on a line of its own.
attributeBubbleStyle string Extra style class of the attribute bubble (for example noise, noise-good, pollution, pollution-good).
textFirst boolean Shows the text before the icon.
layoutType LayoutType Placement in the info panel.

ConstructionDescReactUtil.ConstructionInfoNumberListParam

record base/tealdef/gui/construction/construction_desc_react_util.d.tl:71

record ConstructionInfoNumberListParam

Notes

Parameters of ConstructionInfoNumberList.

Used in the base game: 1 time in 1 file

base/content/gui/gui/construction/construction_desc_react_util.tl:906

construction_desc_react_util.ConstructionInfoNumberList = react.RegisterRecipe("ConstructionInfoNumberList", function(param : ConstructionDescReactUtil.Construc

Fields

Name Type Description
line {FormatNumberDesc} Formatted numbers to show.
vertical boolean Stacks the items vertically instead of a flow layout.
useTitleFont boolean Uses the headline font instead of the body font.

ConstructionDescReactUtil.DepotHudIconsConfigParams

record base/tealdef/gui/construction/construction_desc_react_util.d.tl:78

record DepotHudIconsConfigParams

Notes

Parameters of getDepotHudIconsConfig.

Used in the base game: 2 times in 2 files

base/content/gui/gui/construction/construction_desc_react_util.tl:1017

construction_desc_react_util.getDepotHudIconsConfig = function(capturedParams : ConstructionDescReactUtil.DepotHudIconsConfigParams) : ConstructionActionHudIcon
base/content/gui/gui/construction/construction_desc_hud_icons.script.tl:7
configureDepotHudIconsFn = function(capturedParams : ConstructionDescReactUtil.DepotHudIconsConfigParams) : ConstructionActionHudIcons

Fields

Name Type Description
depotType ConstructionActionHudIconConstructionType Carrier of the depot.

ConstructionDescReactUtil.StationHudIconsConfigParams

record base/tealdef/gui/construction/construction_desc_react_util.d.tl:81

record StationHudIconsConfigParams

Notes

Parameters of getStationHudIconsConfig.

Used in the base game: 2 times in 2 files

base/content/gui/gui/construction/construction_desc_react_util.tl:1041

construction_desc_react_util.getStationHudIconsConfig = function(capturedParams : ConstructionDescReactUtil.StationHudIconsConfigParams) : ConstructionActionHud
base/content/gui/gui/construction/construction_desc_hud_icons.script.tl:4
configureStationHudIconsFn = function(capturedParams : ConstructionDescReactUtil.StationHudIconsConfigParams) : ConstructionActionHudIcons

Fields

Name Type Description
cargo boolean Cargo station; adds warehouse icons.
rail boolean Rail station; adds signal icons.