Skip to content

town_util_parallel

Source: base/tealdef/game_mechanics/towns/town_util_parallel.d.tl

Notes

Town functions for GUI widgets that run through engine_react_util.useStepStateParallel and return plain tables.

TownUtilParallel

record global base/tealdef/game_mechanics/towns/town_util_parallel.d.tl:3

global record TownUtilParallel

Notes

Town functions for GUI widgets. The GUI calls them by script path through engine_react_util.useStepStateParallel or useStepStateParallelSimple, so they return plain tables without userdata.

Example

local state = engine_react_util.useStepStateParallelSimple(
    "::/game_mechanics/towns/town_util_parallel.script@town_util_parallel.getDeliveriesState",
    params.entity) as ReactStateT<TownUtilParallel.DeliveriesState>

Functions

getCargoSupplyDemandsLandUseWithResidentialLineUsage(param : GetCargoSupplyDemandsLandUseParam) : {CargoTypeSupplyDemand} base/tealdef/game_mechanics/towns/town_util_parallel.d.tl:8

Notes

Calls TownUtil.getCargoSupplyDemandsLandUseWithResidentialLineUsage.

Parameter Type Description
param GetCargoSupplyDemandsLandUseParam Town and district type.

Returns {CargoTypeSupplyDemand}: List of supply and demand entries.

getDeliveriesState(townEntity : Engine.Entity) : DeliveriesState base/tealdef/game_mechanics/towns/town_util_parallel.d.tl:21

Notes

Supply ratings of a town.

Parameter Type Description
townEntity Engine.Entity Town entity.

Returns DeliveriesState: Supply rating levels per district and for passengers.

getTrafficWidgetState(townEntity : Engine.Entity) : TrafficWidgetState base/tealdef/game_mechanics/towns/town_util_parallel.d.tl:27

Notes

Data of the traffic widget of a town.

Parameter Type Description
townEntity Engine.Entity Town entity.

Returns TrafficWidgetState: Traffic rating level and street counts.

getHappinessWidgetState(townEntity : Engine.Entity) : HappinessWidgetState base/tealdef/game_mechanics/towns/town_util_parallel.d.tl:32

Notes

Happiness statistics of a town as a plain table.

Parameter Type Description
townEntity Engine.Entity Town entity.

Returns HappinessWidgetState: Happiness statistics.

getNoisePollutionWidgetState(params : TownUtilParallel.NoisePollutionWidgetStateParam) : TownUtilParallel.NoisePollutionWidgetState base/tealdef/game_mechanics/towns/town_util_parallel.d.tl:46

Notes

Noise or pollution rating level of a town and the share of each source.

Parameter Type Description
params TownUtilParallel.NoisePollutionWidgetStateParam Town, emission kind and line options.

Returns TownUtilParallel.NoisePollutionWidgetState: Rating level and shares.

getDeliveryTimeWidgetState(townEntity : Engine.Entity) : DeliveryTimeWidgetState base/tealdef/game_mechanics/towns/town_util_parallel.d.tl:59

Notes

Delivery time rating of a town and the deliveries per line.

Parameter Type Description
townEntity Engine.Entity Town entity.

Returns DeliveryTimeWidgetState: Rating and line statistics.

getRatingUrbanCare(param : GetRatingParam) : RatingLevel base/tealdef/game_mechanics/towns/town_util_parallel.d.tl:67

Notes

Level of TownUtil.getRatingUrbanCare for a town.

Parameter Type Description
param GetRatingParam Town entity and extra param.

Returns RatingLevel: Rating level.

getRatingTraffic(param : GetRatingParam) : RatingLevel base/tealdef/game_mechanics/towns/town_util_parallel.d.tl:68

Notes

Level of TownUtil.getRatingTraffic for a town.

Parameter Type Description
param GetRatingParam Town entity and extra param.

Returns RatingLevel: Rating level.

getRatingHappiness(param : GetRatingParam) : RatingLevel base/tealdef/game_mechanics/towns/town_util_parallel.d.tl:69

Notes

Level of TownUtil.getRatingHappiness for a town.

Parameter Type Description
param GetRatingParam Town entity and extra param.

Returns RatingLevel: Rating level.

getRatingCargoDelivery(param : GetRatingParam) : RatingLevel base/tealdef/game_mechanics/towns/town_util_parallel.d.tl:70

Notes

Level of TownUtil.getRatingCargoDelivery for a town.

Parameter Type Description
param GetRatingParam Town entity and extra param.

Returns RatingLevel: Rating level.

getRatingNoise(param : GetRatingParam) : RatingLevel base/tealdef/game_mechanics/towns/town_util_parallel.d.tl:71

Notes

Level of TownUtil.getRatingNoise for a town.

Parameter Type Description
param GetRatingParam Town entity and extra param.

Returns RatingLevel: Rating level.

getRatingPollution(param : GetRatingParam) : RatingLevel base/tealdef/game_mechanics/towns/town_util_parallel.d.tl:72

Notes

Level of TownUtil.getRatingPollution for a town.

Parameter Type Description
param GetRatingParam Town entity and extra param.

Returns RatingLevel: Rating level.

getRatingBonuses(param : TownUtilParallel.GetRatingParam) : RatingLevel base/tealdef/game_mechanics/towns/town_util_parallel.d.tl:74

Notes

Level of TownUtil.getRatingBonuses for a town (Excellent with an experience bonus, otherwise Good).

Parameter Type Description
param TownUtilParallel.GetRatingParam Town entity and extra param.

Returns RatingLevel: Rating level.

getRatingDeliveries(param : TownUtilParallel.GetRatingParam) : RatingLevel base/tealdef/game_mechanics/towns/town_util_parallel.d.tl:75

Notes

Level of TownUtil.getRatingDeliveries for a town.

Parameter Type Description
param TownUtilParallel.GetRatingParam Town entity and extra param.

Returns RatingLevel: Rating level.

getTownDistrictCountsState(townEntity : Engine.Entity) : TownDistrictCountsState base/tealdef/game_mechanics/towns/town_util_parallel.d.tl:82

Notes

Latest district counts of a town.

Parameter Type Description
townEntity Engine.Entity Town entity.

Returns TownDistrictCountsState: Counts per district.

getTownLevelWidgetState(townEntity : Engine.Entity) : TownLevelWidgetState base/tealdef/game_mechanics/towns/town_util_parallel.d.tl:89

Notes

Experience, growth factor and growth level of a town.

Parameter Type Description
townEntity Engine.Entity Town entity.

Returns TownLevelWidgetState: Town level data; experience 0, growth factor 1 and VeryPoor without growth state.

getTownCapacityUsages(Engine.Entity) : TownCapacityUsages base/tealdef/game_mechanics/towns/town_util_parallel.d.tl:101

Notes

Copy of TownUtil.getTownCapacityUsages as plain tables.

Parameter Type Description
#1 Engine.Entity Town entity.

Returns TownCapacityUsages: Capacity usage per district.

TownUtilParallel.GetCargoSupplyDemandsLandUseParam

record base/tealdef/game_mechanics/towns/town_util_parallel.d.tl:4

record GetCargoSupplyDemandsLandUseParam

Notes

Param of getCargoSupplyDemandsLandUseWithResidentialLineUsage.

Used in the base game: 1 time in 1 file

base/content/game_mechanics/game_mechanics/towns/town_util_parallel.script.tl:7

town_util_parallel.getCargoSupplyDemandsLandUseWithResidentialLineUsage = function(param : TownUtilParallel.GetCargoSupplyDemandsLandUseParam) : {CargoTypeSuppl

Fields

Name Type Description
townEntity Engine.Entity Town entity.
landUse LandUseType District type.

TownUtilParallel.DeliveriesState

record base/tealdef/game_mechanics/towns/town_util_parallel.d.tl:10

record DeliveriesState

Notes

Supply ratings of a town for the supplies widgets.

Used in the base game: 6 times in 2 files

base/content/game_mechanics/game_mechanics/towns/town_util_parallel.script.tl:12

town_util_parallel.getDeliveriesState = function(townEntity : Engine.Entity) : TownUtilParallel.DeliveriesState
base/content/game_mechanics/game_mechanics/towns/town_react_util.tl:264
local state = engine_react_util.useStepStateParallelSimple("::/game_mechanics/towns/town_util_parallel.script@town_util_parallel.getDeliveriesState", params.ent

Fields

Name Type Description
suppliesRating RatingLevel Combined supplies rating level (TownUtil.getRatingDeliveries).
passengerRating integer Level number (0 to 5) of the passenger supply; nil without residential capacity.
noPassengers boolean True when there is no passenger supply.
cargoRatingResidential integer Level number (0 to 5) of the residential cargo supply; nil without demand.
noCargoResidential boolean True when no residential cargo is supplied or demanded.
cargoRatingIndustrial integer Level number (0 to 5) of the industrial cargo supply; nil without demand.
noCargoIndustrial boolean True when no industrial cargo is supplied or demanded.
cargoRatingCommercial integer Level number (0 to 5) of the commercial cargo supply; nil without demand.
noCargoCommercial boolean True when no commercial cargo is supplied or demanded.

TownUtilParallel.TrafficWidgetState

record base/tealdef/game_mechanics/towns/town_util_parallel.d.tl:23

record TrafficWidgetState

Notes

Data of the traffic widget.

Used in the base game: 2 times in 2 files

base/content/game_mechanics/game_mechanics/towns/town_util_parallel.script.tl:31

town_util_parallel.getTrafficWidgetState = function(townEntity : Engine.Entity) : TownUtilParallel.TrafficWidgetState
base/content/game_mechanics/game_mechanics/towns/town_react_util.tl:1411
local state = engine_react_util.useStepStateParallelSimple("::/game_mechanics/towns/town_util_parallel.script@town_util_parallel.getTrafficWidgetState", params.

Fields

Name Type Description
ratingLevel RatingLevel Level of the traffic rating.
streetsPerLevel {integer} Street counts per traffic level from TownUtil.getTrafficSpeedRating; {0} without data.

TownUtilParallel.HappinessWidgetState

record base/tealdef/game_mechanics/towns/town_util_parallel.d.tl:29

record HappinessWidgetState

Notes

Data of the happiness widget.

Used in the base game: 2 times in 2 files

base/content/game_mechanics/game_mechanics/towns/town_util_parallel.script.tl:43

town_util_parallel.getHappinessWidgetState = function(townEntity : Engine.Entity) : TownUtilParallel.HappinessWidgetState
base/content/game_mechanics/game_mechanics/towns/town_react_util.tl:1563
local state = engine_react_util.useStepStateParallelSimple("::/game_mechanics/towns/town_util_parallel.script@town_util_parallel.getHappinessWidgetState", param

Fields

Name Type Description
stats UtilTown.TownHappinessStats Copy of the town's happiness statistics with the top TownUtil.NumLinesForHappinessStats lines.

TownUtilParallel.NoisePollutionWidgetStateParam

record base/tealdef/game_mechanics/towns/town_util_parallel.d.tl:34

record NoisePollutionWidgetStateParam

Notes

Param of getNoisePollutionWidgetState.

Used in the base game: 1 time in 1 file

base/content/game_mechanics/game_mechanics/towns/town_util_parallel.script.tl:76

town_util_parallel.getNoisePollutionWidgetState = function(params : TownUtilParallel.NoisePollutionWidgetStateParam) : TownUtilParallel.NoisePollutionWidgetStat

Fields

Name Type Description
townEntity Engine.Entity Town entity.
pollution boolean True for pollution, false for noise.
byLine boolean Also compute the share per line.
maxLines integer Maximum number of lines listed; the rest is summed into one entry with line -1.

TownUtilParallel.NoisePollutionWidgetState

record base/tealdef/game_mechanics/towns/town_util_parallel.d.tl:40

record NoisePollutionWidgetState

Notes

Data of the noise and pollution widgets.

Used in the base game: 3 times in 2 files

base/content/game_mechanics/game_mechanics/towns/town_util_parallel.script.tl:76

town_util_parallel.getNoisePollutionWidgetState = function(params : TownUtilParallel.NoisePollutionWidgetStateParam) : TownUtilParallel.NoisePollutionWidgetStat
base/content/game_mechanics/game_mechanics/towns/town_react_util.tl:1989
}) as ReactStateT<TownUtilParallel.NoisePollutionWidgetState>

Fields

Name Type Description
emissionRatingLevel RatingLevel pollutionRating : integer
emissionPerSource {{TownUtil.EmitterCategory, integer}} Pairs of source category and percentage, highest first; only entries above 0 %.
emissionPerLine {{Engine.Entity, integer}} Pairs of line entity and percentage, highest first; line -1 stands for all other lines. Set only when byLine is true.

TownUtilParallel.DeliveryTimeWidgetState

record base/tealdef/game_mechanics/towns/town_util_parallel.d.tl:48

record DeliveryTimeWidgetState

Notes

Data of the delivery time widget.

Used in the base game: 2 times in 2 files

base/content/game_mechanics/game_mechanics/towns/town_util_parallel.script.tl:137

town_util_parallel.getDeliveryTimeWidgetState = function(townEntity : Engine.Entity) : TownUtilParallel.DeliveryTimeWidgetState
base/content/game_mechanics/game_mechanics/towns/town_react_util.tl:1673
local state = engine_react_util.useStepStateParallelSimple("::/game_mechanics/towns/town_util_parallel.script@town_util_parallel.getDeliveryTimeWidgetState", pa

Fields

Name Type Description
cargoDeliveryRating integer Delivery time rating as a percentage (0 to 100).
level RatingLevel Level of the delivery time rating.
lineStats {LineStats} Line statistics sorted by late items, then total; at most five entries, the fifth combines the remaining lines.

TownUtilParallel.DeliveryTimeWidgetState.LineStats

record base/tealdef/game_mechanics/towns/town_util_parallel.d.tl:51

record LineStats

Notes

Cargo deliveries of one line to the town in the last half game year.

Used in the base game: 6 times in 2 files

base/content/game_mechanics/game_mechanics/towns/town_util_parallel.script.tl:141

local linesStats : {Engine.Entity : TownUtilParallel.DeliveryTimeWidgetState.LineStats} = {}
base/content/game_mechanics/game_mechanics/towns/town_react_util.tl:1694
local addLineStats = function(lineStat : TownUtilParallel.DeliveryTimeWidgetState.LineStats)

Fields

Name Type Description
entity Engine.Entity Line entity; -1 for the combined remaining lines.
cargoTypes {CargoTypeId} Cargo types delivered by the line, most delivered first.
total integer Number of items delivered.
late integer Number of items delivered late.

TownUtilParallel.GetRatingParam

record base/tealdef/game_mechanics/towns/town_util_parallel.d.tl:63

record GetRatingParam

Notes

Param of the parallel rating functions; the GUI builds it from TownUtil.Rating.

Used in the base game: 8 times in 1 file

base/content/game_mechanics/game_mechanics/towns/town_util_parallel.script.tl:233

town_util_parallel.getRatingUrbanCare = function(param : TownUtilParallel.GetRatingParam) : RatingLevel

Fields

Name Type Description
townEntity Engine.Entity Town entity.
extraParam any Value of TownUtil.Rating.getRatingFnExtraParam; the base-game functions ignore it.

TownUtilParallel.TownDistrictCountsState

record base/tealdef/game_mechanics/towns/town_util_parallel.d.tl:77

record TownDistrictCountsState

Notes

Latest district counts of a town from its logbook.

Used in the base game: 2 times in 2 files

base/content/gui/gui/entity_window/town/town_eow.script.tl:1110

local dataState = engine_react_util.useStepStateParallel("::/game_mechanics/towns/town_util_parallel.script@town_util_parallel.getTownDistrictCountsState", para
base/content/game_mechanics/game_mechanics/towns/town_util_parallel.script.tl:290
town_util_parallel.getTownDistrictCountsState = function(townEntity : Engine.Entity) : TownUtilParallel.TownDistrictCountsState

Fields

Name Type Description
numResidential integer Most recent logbook value townResidentialCount.
numCommercial integer Most recent logbook value townCommercialCount.
numIndustrial integer Most recent logbook value townIndustrialCount.

TownUtilParallel.TownLevelWidgetState

record base/tealdef/game_mechanics/towns/town_util_parallel.d.tl:84

record TownLevelWidgetState

Notes

Data of the town level widget.

Used in the base game: 2 times in 2 files

base/content/gui/gui/entity_window/town/town_eow.script.tl:27

local stepState = engine_react_util.useStepStateParallelSimple("::/game_mechanics/towns/town_util_parallel.script@town_util_parallel.getTownLevelWidgetState", p
base/content/game_mechanics/game_mechanics/towns/town_util_parallel.script.tl:267
town_util_parallel.getTownLevelWidgetState = function(townEntity : Engine.Entity) : TownUtilParallel.TownLevelWidgetState

Fields

Name Type Description
experience integer Experience of the town.
growthFactor number Growth factor from TownCargoUtil.getGrowthFactor.
growthLevel RatingLevel Growth level from TownUtil.getGrowthLevelMult.

TownUtilParallel.TownCapacityUsage

record base/tealdef/game_mechanics/towns/town_util_parallel.d.tl:92

record TownCapacityUsage

note: Can't use UtilTown.TownCapacityUsage because useFn() cannot return userdata

Fields

Name Type Description
used integer Used capacity.
capacity integer Total capacity.

TownUtilParallel.TownCapacityUsages

record base/tealdef/game_mechanics/towns/town_util_parallel.d.tl:96

record TownCapacityUsages

Notes

Used and total capacity per district, as plain tables.

Used in the base game: 2 times in 2 files

base/content/gui/gui/entity_window/town/town_eow.script.tl:32

local growthStatsState = engine_react_util.useStepStateParallelSimple("::/game_mechanics/towns/town_util_parallel.script@town_util_parallel.getTownCapacityUsage
base/content/game_mechanics/game_mechanics/towns/town_util_parallel.script.tl:298
town_util_parallel.getTownCapacityUsages = function(townEntity : Engine.Entity) : TownUtilParallel.TownCapacityUsages

Fields

Name Type Description
residential TownCapacityUsage Capacity usage of the residential district.
commercial TownCapacityUsage Capacity usage of the commercial district.
industrial TownCapacityUsage Capacity usage of the industrial district.