Files
tpf3-overtake/docs/reference/script-doc/api_engine_util.md

4383 lines
136 KiB
Markdown

<!-- Source: https://wiki.transportfever3.com/script-doc/api/engine/util.html (fetched 2026-10-04) -->
[index](../../index.html) / [api](../../api.html) / [engine](../engine.html) / util
---
# Module api.engine.util[🔗](#api.engine.util)
Contains definitions for of api.engine.util
```
global record EngineUtil getPlayer: function(): Engine.Entity
getWorld: function(): Engine.Entity
getCalendarDate: function(gameTime : number): Date
getYear: function(): integer
hasStartedAsMission: function(): boolean
getEntityName: function(Engine.Entity): string
getEntityNameStem: function(Engine.Entity): {string, Engine.Entity}
cargo: UtilCargo
construction: UtilConstruction
chart: UtilChart
finance: UtilFinance
headquarters: UtilHeadquarters
line: UtilLine
logbook: UtilLogbook
maintenance: UtilMaintenance
octree: UtilOctree
parallelStrip: UtilParallelStrip
pathfinding: UtilPathfinding
station: UtilStation
stock: UtilStock
town: UtilTown
transport: UtilTransport
vehicle: UtilVehicle
industry: UtilIndustry
proposal: UtilProposal
emission: UtilEmission
formatAge: function(begin : integer, end : integer): string
end
[Expand All] [Collapse All]
global record UtilCargo isGoodQuality: function(sim : Engine.Entity): boolean
record CargoQualityData clone: function(CargoQualityData): CargoQualityData
countBad: integer
countTotal: integer
averageQuality: number | nil
isVeryBad: boolean
end
record SummarizedCargoQualityData clone: function(SummarizedCargoQualityData): SummarizedCargoQualityData
passengers: CargoQualityData
cargo: CargoQualityData
end
getCargoQualityDataForLine: function(lineEntity : Engine.Entity, cargoTypeId : CargoTypeId): UtilCargo.CargoQualityData
getCargoQualityDataForVehicle: function(vehicleEntity : Engine.Entity, cargoTypeId : CargoTypeId): UtilCargo.CargoQualityData
getCargoQualityDataAtStation: function(stationEntity : Engine.Entity, cargoTypeId : CargoTypeId): UtilCargo.CargoQualityData
getCargoQualityDataAtStationGroup: function(stationGroupEntity : Engine.Entity, cargoTypeId : CargoTypeId): UtilCargo.CargoQualityData
getCargoQualityDataAtStop: function(lineEntity : Engine.Entity, stopIndex : integer, cargoTypeId : CargoTypeId): UtilCargo.CargoQualityData
getCargoQualityDataAtTerminal: function(stationGroupEntity : Engine.Entity, stationTerminal : StationTerminal, cargoTypeId : CargoTypeId): UtilCargo.CargoQualityData
getCargoQualityDataForStockList: function(stockListEntity : Engine.Entity, cargoTypeId : CargoTypeId): UtilCargo.CargoQualityData
getCargoQualityDataForStock: function(stockListEntity : Engine.Entity, stockId : StockId, cargoTypeId : CargoTypeId): UtilCargo.CargoQualityData
getSummarizedCargoQualityDataForStockList: function(stockListEntity : Engine.Entity): UtilCargo.SummarizedCargoQualityData
getSummarizedCargoQualityDataForLine: function(lineEntity : Engine.Entity): UtilCargo.SummarizedCargoQualityData
getSummarizedCargoQualityDataForVehicle: function(vehicleEntity : Engine.Entity): UtilCargo.SummarizedCargoQualityData
getNumCargoPerTypeInVehicle: function(vehicleEntity : Engine.Entity): {integer}
end
global record UtilChart getChartLabel: function(config : ChartConfig, index : integer, abbreviated : boolean): string
setLastValue: function(chartResult : ChartResult, series : integer, value : number)
end
global record UtilConstruction getNumAndFilledAutoFillSlots: function(entity : Engine.Entity): {integer, integer}
getConstructionEntity: function(depotEntity : Engine.Entity): Engine.Entity
getSlotTypes: function(entity : Engine.Entity): {string}
getConstructionResult: function(constructionResName : ResName, constructionTemplate : integer, parameters : {<any type> : <any type>}): ConstructionResult
getGlobalConstructionParams: function(): {string : number}
getCostMultiplierForYear: function(costMultipliers : {integer : number}, currentYear : integer): number
findSegmentsToDelete: function(constructionEntity : Engine.Entity, keepIndustryRoads : boolean): {Engine.Entity}
end
global record UtilEmission getCurrentEmission: function(entity : Engine.Entity, type : Engine.Component.EmissionGrid.Type): number
getPollutionEmittersInSettlementArea: function(entity : Engine.Entity): {{Engine.Entity, number}}
getNoiseEmittersNearSettlementLandUses: function(entity : Engine.Entity, distance : number, landUseTypes : {LandUseType}): {{Engine.Entity, number}}
end
global record UtilFinance getAccountChart: function(entity : Engine.Entity, config : ChartConfig): ChartResult
getDebtChart: function(entity : Engine.Entity, config : ChartConfig, integer): ChartResult
calculateBalance: function(entities : {Engine.Entity}, begin : integer, end : integer, true : boolean, only : JournalEntry.Maintenance): integer
calculateEarnings: function(playerEntity : Engine.Entity): integer
computeFinanceTable: function(playerEntity : Engine.Entity, config : ChartConfig): FinanceData
getPlayersBalance: function(playerEntity : Engine.Entity): integer
calcIncomeSince: function(current : number, playerEntity : Engine.Entity): number
getLastIncomeTime: function(playerEntity : Engine.Entity): integer
getFirstIncomeTime: function(playerEntity : Engine.Entity): integer
end
global record UtilHeadquarters getTransportedData: function(): TransportationStats
getCompaniesValue: function(): CompanyValue
end
[Expand All] [Collapse All]
global record UtilIndustry record IndustryProductivityInfo producing: boolean
boostFromRule: boolean
boostFromPersonCapacity: boolean
end
getIndustryProductivityInfo: function(entity : Engine.Entity): IndustryProductivityInfo
getClosingIndustries: function(): {{Engine.Entity, ResName}}
getEconomyCargoDependencies: function(economyId : integer): {string : {string : number}}
end
[Expand All] [Collapse All]
global record UtilLine record LineCapacityUsage used: number
capacity: number
end
record PathProblemLocation edgeIndex: integer
node: NodeId
nodePosition: Vec3f
okModes: {TransportMode : boolean}
relaxedModes: {TransportMode : boolean}
allowedModes: {TransportMode : boolean}
end
record TerminalCapacityUsage equals: function(TerminalCapacityUsage, TerminalCapacityUsage): boolean
used: number
capacity: number
end
record StopState empty: boolean
noPath: boolean
noPathFromAlternative: {integer, PathProblemLocation}
noPathToAlternative: {integer, PathProblemLocation}
duplicateStop: boolean
incompatibleStop: boolean
noPathLocation: PathProblemLocation
end
getLineCapacityUsages: function(line : Engine.Entity, allCapacities : boolean): {CargoTypeId : LineCapacityUsage}
calcLineStationThroughput: function(lineEntity : Engine.Entity): integer
getMaxFrequency: function(lineEntity : Engine.Entity): number
getDetailedLineProblems: function(lineEntity : Engine.Entity): {{StopState}}
getLineProblems: function(): {{Engine.Entity, integer, PathProblemLocation}}
getLineStationProblems: function(): {{Engine.Entity, Engine.Entity, LineStationProblem}}
isLineCompatibleWithCarrier: function(lineEntity : Engine.Entity, carrier : Carrier, distinguishTramFromRoad : boolean): boolean
isLineCompatibleWithAnyCarrier: function(lineEntity : Engine.Entity, carriers : {Carrier}, distinguishTramFromRoad : boolean): boolean
supportsReservation: function(lineEntity : Engine.Entity): boolean
getLineIssues: function(lineEntity : Engine.Entity, allIssues : boolean): {LineIssue}
getLinesIssues: function(playerEntity : Engine.Entity, allIssues : boolean): {Engine.Entity : {LineIssue}}
getFailedPathReason: function(vehicle : Engine.Entity, line : Engine.Entity, fullLine : boolean): Failure
getNoRoadConnectionProblems: function(): {Engine.Entity}
end
global record UtilLogbook getLogValuePerYear: function(entity : Engine.Entity, logName : string): integer
getLogValueMostRecent: function(entity : Engine.Entity, logName : string): integer
getLogValueOldest: function(entity : Engine.Entity, logName : string): integer
logValue: function(entity : Engine.Entity, logName : string, value : integer)
getChart: function(logbookEntity : Engine.Entity, logNames : {string}, xMin : number, xMax : number, yMin : number, yMax : number, ChartConfig : ChartConfig): ChartResult
getChartDiff: function(entity : Engine.Entity, logNames : {string}, config : ChartConfig): ChartResult
end
global record UtilMaintenance calcMaintenanceForStationGroup: function(stationGroupEntity : Engine.Entity): integer
calcMaintenanceForSubconstruction: function(subconstructionEntity : Engine.Entity): integer
end
global record UtilOctree findEntitiesInCircle: function(center : Vec2f, radius : number, componentType : Engine.ComponentType): {Engine.Entity}
findTransportNetworkNodesInCircle: function(center : Vec2f, radius : number): {NodeId}
areWaypointsOnLine: function(waypoints : {Vec2f}, lineEntity : Engine.Entity, tolerance : number): boolean
end
[Expand All] [Collapse All]
global record UtilParallelStrip record StripInfo carrier: Carrier
edgeType: BaseEdgeType
edgeTypeIndex: integer
end
getStripInfo: function(entity : Engine.Entity): StripInfo
isBridge: function(entity : Engine.Entity): boolean
isTunnel: function(entity : Engine.Entity): boolean
end
[Expand All] [Collapse All]
global record UtilPathfinding record EdgeIdDirAndLength edgeId: EdgeId
dir: boolean
length: number
new: function(EdgeId, boolean, number): EdgeIdDirAndLength
end
record EdgeIdDir edgeId: EdgeId
dir: boolean
new: function(EdgeId, boolean): EdgeIdDir
end
findPath: function(startingEdgesAndLengths : {EdgeIdDirAndLength}, destinationNodes : {NodeId}, transportModeSet : {TransportMode}, maxLength : number): {{EdgeId, boolean}}
findPathNodeToNode: function(startNodes : {NodeId}, destinationNodes : {NodeId}, transportModeSet : {TransportMode}): {{EdgeId, boolean}}
getTargetsByLandUse: function(): {<any type> : <any type>}
findDubinsPath: function(p0 : Vec3f, t0 : Vec3f, p1 : Vec3f, t1 : Vec3f, turnRadius : number): {{EdgeGeometry, boolean}}
end
global record UtilProposal makeProposalData: function(Proposal, Context): ProposalData
makeIndustrySpawnProposal: function(industryTypeTag : string, townEntity : Engine.Entity): Proposal
makeSegmentsRemoveProposal: function(segmentsToRemove : {Engine.Entity}): Proposal
createProposalRemove: function(entity : Engine.Entity, context : Context): Proposal
createProposalReplaceConstruction: function(entity : Engine.Entity, params : {<any type> : <any type>}, newResName : ResName): Proposal
createIndustryProposal: function(seed : string, industryRectangle : IndustryInfo, context : Context): Proposal
createBridgeOrTunnelProposal: function(parallelStripEntity : Engine.Entity, newTypeIndex : integer): Proposal
createDoubleSlipSwitchProposal: function(entity : Engine.Entity, doubleSlipSwitch : boolean): Proposal
createTrafficLightProposal: function(entity : Engine.Entity, trafficLightConfig : Engine.Component.TrafficLightConfig, trafficLightPreference : TrafficLightPreference): Proposal
getBridgeOrTunnelRelatedRevisions: function(parallelStripEntity : Engine.Entity): {Engine.Entity : Engine.Revision}
didBridgeOrTunnelRelatedRevisionsChange: function(parallelStripEntity : Engine.Entity, revisions : {Engine.Entity : Engine.Revision}): boolean
makeReforestationProposal: function(seed : integer, numTilesToUpdate : integer, maxTreesPerTile : integer): Proposal
refreshConstruction: function(entity : Engine.Entity, constructionFilepath : string): Proposal
replaceSegment: function(entity : Engine.Entity, streetTemplate : ResName): Proposal
checkProposalConnectsNodes: function(startNode : Engine.Entity, startEdge : Engine.Entity, targetNode : Engine.Entity, streetProposal : Proposal.StreetProposal, isApply : boolean, maxDepth : number): boolean
makeIndustryExtendProposal: function(industry : Engine.Entity, trySlots : integer, numExtendSlots : integer): {Proposal, {integer}}
createSubconstructionLotList: function(Proposal.Subconstruction, Mat4f): Engine.Component.LotList
getConstructionArea: function(proposal : Proposal): number
end
[Expand All] [Collapse All]
global record UtilStation record StationUsage totalUsed: integer
overflow: integer
poolCapacity: integer
terminalCapacity: integer
end
calculateStationUsage: function(station : Engine.Entity): StationUsage
calculateStationTerminalUsage: function(station : Engine.Entity, terminalIndex : integer): UtilLine.TerminalCapacityUsage
record StationGroupCapacityUsage equals: function(StationGroupCapacityUsage, StationGroupCapacityUsage): boolean
capacity: integer
waitingHallCapacity: integer
used: integer
overflow: boolean
end
calculateStationGroupCargo: function(stationGroup : Engine.Entity, flatTerminalIndex : integer): StationGroupCapacityUsage
isStationOfType: function(stationEntity : Engine.Entity, cargo : boolean): boolean
findStationGroupWithOverlappingCatchmentOfDifferentCarriers: function(): {{Engine.Entity, Engine.Entity}}
end
global record UtilStock getStockCargoTypes: function(stockListEntity : Engine.Entity, stockId : StockId): {CargoTypeId}
getCargoTypeShippedPerYear: function(stockListEntity : Engine.Entity, cargoTypeId : CargoTypeId): integer
getCargoShippedPerYear: function(stockListEntity : Engine.Entity): integer
getCargoTypeDeliveredPerYear: function(stockListEntity : Engine.Entity, cargoTypeId : CargoTypeId): integer
getCargoDeliveredPerYear: function(stockListEntity : Engine.Entity): integer
getCargoConsumedPerYear: function(stockListEntity : Engine.Entity, cargoTypeId : CargoTypeId): integer
getCargoProducedPerYear: function(stockListEntity : Engine.Entity, cargoTypeId : CargoTypeId): integer
getCargoMaxProductionPerYear: function(stockListEntity : Engine.Entity, cargoTypeId : CargoTypeId): integer
getCargoMaxConsumptionPerYear: function(stockListEntity : Engine.Entity, cargoTypeId : CargoTypeId): integer
getInputsOutputsFromRules: function(stockListEntity : Engine.Entity): {{CargoTypeId}, {CargoTypeId}}
getCargoOutputPerYear: function(stockListEntity : Engine.Entity): integer
getCargoLogValueDiffPerYear: function(stockListEntity : Engine.Entity, logType : string, cargoTypeId : CargoTypeId): integer
getCargoLogPerYearForTarget: function(sourceStockListEntity : Engine.Entity, targetStockListEntity : Engine.Entity, logType : string, cargoTypeId : CargoTypeId): integer
getCargoLogPerYearForTargetFilter: function(sourceStockListEntity : Engine.Entity, targetFilter : function(Engine.Entity) : boolean, logType : string, cargoTypeId : CargoTypeId): integer
getProductionRating: function(stockListEntity : Engine.Entity): number
getStockGroupsByTypeAndCargoTypes: function(stockListEntity : Engine.Entity, sortByType : boolean, showEmpty : boolean): {{StockListType, {StockId}, {CargoTypeId}, integer}}
getStockListsWithThrownAwayCargo: function(): {Engine.Entity : integer}
hasAnyCompatibleStock: function(entities : {Engine.Entity}, cargoTypeId : CargoTypeId, load : boolean): boolean
getAdjustedDeliveryTime: function(cargoTypeId : CargoTypeId): integer
isCargoTypeCurrentlyProduced: function(cargoTypeId : CargoTypeId): boolean
end
[Expand All] [Collapse All]
global record UtilTown record TownReachability commercialPrivate: integer
commercialPublic: integer
industrialPrivate: integer
industrialPublic: integer
end
record TownCapacityUsage used: integer
capacity: integer
end
record TownEmission noise: number
pollution: number
areaSquareKm: number
end
record DestinationUseCount count: integer
linesUseCount: integer
end
record TownHappinessStats record ByResident resident: {integer, integer}
nonResident: {integer, integer}
end
travellingInside: {integer, integer}
travellingTo: ByResident
travellingFrom: ByResident
atBuilding: {integer, integer}
byCar: {integer, integer}
walking: {integer, integer}
byLine: {{Engine.Entity, ByResident}}
end
computeWeightedTargetTownBuildingCapacityPerType: function(townEntity : Engine.Entity): {{integer, integer, integer, integer}}
computeUnweightedTargetTownBuildingCapacityPerType: function(townEntity : Engine.Entity): {{integer, integer, integer, integer}}
computeActualTownBuildingCapacityPerType: function(townEntity : Engine.Entity): {{integer, integer, integer, integer}}
getLandUse2CargoTypes: function(): {LandUseType : {CargoTypeId}}
getTownReachability: function(townEntity : Engine.Entity): TownReachability
getTownEmission: function(townEntity : Engine.Entity): TownEmission
getTownEmissionDB: function(townEntity : Engine.Entity): TownEmission
getTownCapacityUsage: function(townEntity : Engine.Entity): {TownCapacityUsage}
getTownHappinessStats: function(townEntity : Engine.Entity, numTopLines : integer): TownHappinessStats
getTownDeliveriesStats: function(townEntity : Engine.Entity, interval : integer, perLine : boolean, perCargoType : boolean): {Engine.Entity : {CargoTypeId : {integer, integer}}}
getTownStockCargo: function(townEntity : Engine.Entity): {CargoTypeId : {integer, integer}}
getTerrainBrushVolumeImpact: function(proposal : Proposal): {Engine.Entity : {number, number}}
getTerrainAlignmentImpact: function(proposalData : ProposalData): {Engine.Entity : {number, number}}
getAutoRemovalEntityImpact: function(proposalData : ProposalData): {Engine.Entity : {number, number}}
getTownNoisePerDistrict: function(townEntity : Engine.Entity, landUseTypes : {LandUseType}): {LandUseType : {number, integer}}
getImpactFromDistance: function(distance : number): number
computeTownsTrafficSpeedMap: function(samplesCoefficient : number): {Engine.Entity : {number, {integer}}}
getTownProblems: function(): {{{Engine.Entity}, TownProblem}}
isNeighbourTown: function(townEntity1 : Engine.Entity, townEntity2 : Engine.Entity): boolean
getClosestTown: function(position : Vec3f): Engine.Entity
getRandomTownPosition: function(townEntity : Engine.Entity, seed : integer): Vec2f
isLineStoppingInTown: function(lineEntity : Engine.Entity, townEntity : Engine.Entity): boolean
getTownLineUsage: function(townEntity : Engine.Entity): number
getSourceToDestinationCount: function(townEntitiy : Engine.Entity, destinationIsTownMap : {Engine.Entity : boolean}, selectLandUse : integer): {Engine.Entity : DestinationUseCount}
getTownDistrictCenter: function(entity : Engine.Entity, landUseTypes : LandUseType): Vec3f
end
global record UtilTransport calcPosition: function(eg : EdgeGeometry, t : number): Vec3f
calcPositionAndDirection: function(eg : EdgeGeometry, t : number, forward : boolean): {Vec3f}
transportModesToCarriers: function(transportModes : {TransportMode}): {Carrier}
getStartPort: function(edge : {EdgeId, boolean}): PortId
getEndPort: function(edge : {EdgeId, boolean}): PortId
isPortLocked: function(port : integer): boolean
end
global record UtilVehicle findBestLineAndDepotForVehicle: function(vehicleEntity : Engine.Entity): {Engine.Entity, Engine.Entity}
findBestDepotForLine: function(carrier : Carrier, transportModes : {TransportMode}, lineEntity : Engine.Entity, position : Vec3f): Engine.Entity
getSpeed: function(vehicleEntity : Engine.Entity): number
getPosition: function(vehicleEntity : Engine.Entity): Vec3f
calcPathPosData: function(vehicleEntity : Engine.Entity): PathPosData
getDirection: function(vehicleEntity : Engine.Entity): Vec3f
getVehiclesByCarrier: function(carrier : Carrier): {Engine.Entity}
getVehicles: function(): {Engine.Entity}
getRunningCost: function(vehicleEntity : Engine.Entity): number
getDepreciatedValue: function(vehicleEntity : Engine.Entity): integer
getPartPrice: function(part : TransportVehiclePart): integer
getLength: function(modelAsset : Model): number
getAllCargoForCargoTypeSet: function(cargoTypeSet : CargoTypeSet): {CargoTypeId}
getVehicleLoadedCargoTypes: function(vehicleEntity : Engine.Entity): {CargoTypeId}
getVehicleProblems: function(): {{{Engine.Entity}, VehicleProblem}}
getMaintenanceEmissionPenalty: function(maintenanceState : number): number
getMaintenanceComfortPenalty: function(maintenanceState : number): number
getMaintenanceTopSpeedPenalty: function(topSpeedMaintenanceFactorPenaltyPerLevel : number, maintenanceState : number): number
getMaintenanceRunningCostPenalty: function(maintenanceState : number): number
getVehicleType: function(vehicleEntity : Engine.Entity): integer
getVehicleCapacities: function(vehicleEntity : Engine.Entity): {integer}
getVehicleUnsetCapacities: function(vehicleEntity : Engine.Entity): {{integer}}
end
```
## Category: main[🔗](#category-main)
### EngineUtil[🔗](#$api.engine.util~EngineUtil)
```
global record EngineUtil getPlayer: function(): Engine.Entity
getWorld: function(): Engine.Entity
getCalendarDate: function(gameTime : number): Date
getYear: function(): integer
hasStartedAsMission: function(): boolean
getEntityName: function(Engine.Entity): string
getEntityNameStem: function(Engine.Entity): {string, Engine.Entity}
cargo: UtilCargo
construction: UtilConstruction
chart: UtilChart
finance: UtilFinance
headquarters: UtilHeadquarters
line: UtilLine
logbook: UtilLogbook
maintenance: UtilMaintenance
octree: UtilOctree
parallelStrip: UtilParallelStrip
pathfinding: UtilPathfinding
station: UtilStation
stock: UtilStock
town: UtilTown
transport: UtilTransport
vehicle: UtilVehicle
industry: UtilIndustry
proposal: UtilProposal
emission: UtilEmission
formatAge: function(begin : integer, end : integer): string
end
```
Collection of engine specific utils grouped by system
### EngineUtil.getPlayer[🔗](#$api.engine.util~EngineUtil.getPlayer)
```
function EngineUtil.getPlayer(): Engine.Entity
```
Obtains the player entity.
**Returns**
1. `Engine.Entity` — entity id
### EngineUtil.getWorld[🔗](#$api.engine.util~EngineUtil.getWorld)
```
function EngineUtil.getWorld(): Engine.Entity
```
Obtains the world entity.
**Returns**
1. `Engine.Entity` — entity id
### EngineUtil.getCalendarDate[🔗](#$api.engine.util~EngineUtil.getCalendarDate)
```
function EngineUtil.getCalendarDate(gameTime : number): Date
```
Return the calendar date of the gametime, assuming current ingame speed.
**Parameters**
* `gameTime` :`number` — gametime for which to obtain the date
**Returns**
1. `Date` — calendar date matching the game time at the current speed
### EngineUtil.getYear[🔗](#$api.engine.util~EngineUtil.getYear)
```
function EngineUtil.getYear(): integer
```
**Returns**
1. `integer`
### EngineUtil.hasStartedAsMission[🔗](#$api.engine.util~EngineUtil.hasStartedAsMission)
```
function EngineUtil.hasStartedAsMission(): boolean
```
Returns true if currently an active mission, started from the menu, is running
**Returns**
1. `boolean` — true if mission is running
### EngineUtil.getEntityName[🔗](#$api.engine.util~EngineUtil.getEntityName)
```
function EngineUtil.getEntityName(Engine.Entity): string
```
Get name of an (existing) entity, computing it from the base construction if needed.
**Parameters**
* `Engine.Entity`
**Returns**
1. `string` — string Entity name, or nil
### EngineUtil.getEntityNameStem[🔗](#$api.engine.util~EngineUtil.getEntityNameStem)
```
function EngineUtil.getEntityNameStem(Engine.Entity): {string, Engine.Entity}
```
Get name stem of an (existing) entity
**Parameters**
* `Engine.Entity`
**Returns**
1. `{string, Engine.Entity}` — string Entity name and Entity where the stem came from (both can be nil)
### EngineUtil.cargo[🔗](#$api.engine.util~EngineUtil.cargo)
```
EngineUtil.cargo: UtilCargo
```
### EngineUtil.construction[🔗](#$api.engine.util~EngineUtil.construction)
```
EngineUtil.construction: UtilConstruction
```
### EngineUtil.chart[🔗](#$api.engine.util~EngineUtil.chart)
```
EngineUtil.chart: UtilChart
```
### EngineUtil.finance[🔗](#$api.engine.util~EngineUtil.finance)
```
EngineUtil.finance: UtilFinance
```
### EngineUtil.headquarters[🔗](#$api.engine.util~EngineUtil.headquarters)
```
EngineUtil.headquarters: UtilHeadquarters
```
### EngineUtil.line[🔗](#$api.engine.util~EngineUtil.line)
```
EngineUtil.line: UtilLine
```
### EngineUtil.logbook[🔗](#$api.engine.util~EngineUtil.logbook)
```
EngineUtil.logbook: UtilLogbook
```
### EngineUtil.maintenance[🔗](#$api.engine.util~EngineUtil.maintenance)
```
EngineUtil.maintenance: UtilMaintenance
```
### EngineUtil.octree[🔗](#$api.engine.util~EngineUtil.octree)
```
EngineUtil.octree: UtilOctree
```
### EngineUtil.parallelStrip[🔗](#$api.engine.util~EngineUtil.parallelStrip)
```
EngineUtil.parallelStrip: UtilParallelStrip
```
### EngineUtil.pathfinding[🔗](#$api.engine.util~EngineUtil.pathfinding)
```
EngineUtil.pathfinding: UtilPathfinding
```
### EngineUtil.station[🔗](#$api.engine.util~EngineUtil.station)
```
EngineUtil.station: UtilStation
```
### EngineUtil.stock[🔗](#$api.engine.util~EngineUtil.stock)
```
EngineUtil.stock: UtilStock
```
### EngineUtil.town[🔗](#$api.engine.util~EngineUtil.town)
```
EngineUtil.town: UtilTown
```
### EngineUtil.transport[🔗](#$api.engine.util~EngineUtil.transport)
```
EngineUtil.transport: UtilTransport
```
### EngineUtil.vehicle[🔗](#$api.engine.util~EngineUtil.vehicle)
```
EngineUtil.vehicle: UtilVehicle
```
### EngineUtil.industry[🔗](#$api.engine.util~EngineUtil.industry)
```
EngineUtil.industry: UtilIndustry
```
### EngineUtil.proposal[🔗](#$api.engine.util~EngineUtil.proposal)
```
EngineUtil.proposal: UtilProposal
```
### EngineUtil.emission[🔗](#$api.engine.util~EngineUtil.emission)
```
EngineUtil.emission: UtilEmission
```
### EngineUtil.formatAge[🔗](#$api.engine.util~EngineUtil.formatAge)
```
function EngineUtil.formatAge(begin : integer, end : integer): string
```
Format age of a vehicle using current ingame speed.
**Parameters**
* `begin` :`integer` — timestamp of the time interval
* `end` :`integer` — timestamp of the time interval
**Returns**
1. `string` — formatted output, e.g. "6 years"
## Category: globals[🔗](#category-globals)
### UtilCargo[🔗](#$api.engine.util~UtilCargo)
```
[Expand All] [Collapse All]
global record UtilCargo isGoodQuality: function(sim : Engine.Entity): boolean
record CargoQualityData clone: function(CargoQualityData): CargoQualityData
countBad: integer
countTotal: integer
averageQuality: number | nil
isVeryBad: boolean
end
record SummarizedCargoQualityData clone: function(SummarizedCargoQualityData): SummarizedCargoQualityData
passengers: CargoQualityData
cargo: CargoQualityData
end
getCargoQualityDataForLine: function(lineEntity : Engine.Entity, cargoTypeId : CargoTypeId): UtilCargo.CargoQualityData
getCargoQualityDataForVehicle: function(vehicleEntity : Engine.Entity, cargoTypeId : CargoTypeId): UtilCargo.CargoQualityData
getCargoQualityDataAtStation: function(stationEntity : Engine.Entity, cargoTypeId : CargoTypeId): UtilCargo.CargoQualityData
getCargoQualityDataAtStationGroup: function(stationGroupEntity : Engine.Entity, cargoTypeId : CargoTypeId): UtilCargo.CargoQualityData
getCargoQualityDataAtStop: function(lineEntity : Engine.Entity, stopIndex : integer, cargoTypeId : CargoTypeId): UtilCargo.CargoQualityData
getCargoQualityDataAtTerminal: function(stationGroupEntity : Engine.Entity, stationTerminal : StationTerminal, cargoTypeId : CargoTypeId): UtilCargo.CargoQualityData
getCargoQualityDataForStockList: function(stockListEntity : Engine.Entity, cargoTypeId : CargoTypeId): UtilCargo.CargoQualityData
getCargoQualityDataForStock: function(stockListEntity : Engine.Entity, stockId : StockId, cargoTypeId : CargoTypeId): UtilCargo.CargoQualityData
getSummarizedCargoQualityDataForStockList: function(stockListEntity : Engine.Entity): UtilCargo.SummarizedCargoQualityData
getSummarizedCargoQualityDataForLine: function(lineEntity : Engine.Entity): UtilCargo.SummarizedCargoQualityData
getSummarizedCargoQualityDataForVehicle: function(vehicleEntity : Engine.Entity): UtilCargo.SummarizedCargoQualityData
getNumCargoPerTypeInVehicle: function(vehicleEntity : Engine.Entity): {integer}
end
```
### UtilCargo.isGoodQuality[🔗](#$api.engine.util~UtilCargo.isGoodQuality)
```
function UtilCargo.isGoodQuality(sim : Engine.Entity): boolean
```
Check if a cargo is in time / a person is happy
**Parameters**
* `sim` :`Engine.Entity` — cargo or person entity
**Returns**
1. `boolean` — true if good quality
### UtilCargo.CargoQualityData[🔗](#$api.engine.util~UtilCargo.CargoQualityData)
```
record UtilCargo.CargoQualityData clone: function(CargoQualityData): CargoQualityData
countBad: integer
countTotal: integer
averageQuality: number | nil
isVeryBad: boolean
end
```
### UtilCargo.CargoQualityData.clone[🔗](#$api.engine.util~UtilCargo.CargoQualityData.clone)
```
function UtilCargo.CargoQualityData.clone(CargoQualityData): CargoQualityData
```
**Parameters**
* `CargoQualityData`
**Returns**
1. `CargoQualityData`
### UtilCargo.CargoQualityData.countBad[🔗](#$api.engine.util~UtilCargo.CargoQualityData.countBad)
```
UtilCargo.CargoQualityData.countBad: integer
```
### UtilCargo.CargoQualityData.countTotal[🔗](#$api.engine.util~UtilCargo.CargoQualityData.countTotal)
```
UtilCargo.CargoQualityData.countTotal: integer
```
### UtilCargo.CargoQualityData.averageQuality[🔗](#$api.engine.util~UtilCargo.CargoQualityData.averageQuality)
```
UtilCargo.CargoQualityData.averageQuality: number | nil
```
### UtilCargo.CargoQualityData.isVeryBad[🔗](#$api.engine.util~UtilCargo.CargoQualityData.isVeryBad)
```
UtilCargo.CargoQualityData.isVeryBad: boolean
```
### UtilCargo.SummarizedCargoQualityData[🔗](#$api.engine.util~UtilCargo.SummarizedCargoQualityData)
```
record UtilCargo.SummarizedCargoQualityData clone: function(SummarizedCargoQualityData): SummarizedCargoQualityData
passengers: CargoQualityData
cargo: CargoQualityData
end
```
### UtilCargo.SummarizedCargoQualityData.clone[🔗](#$api.engine.util~UtilCargo.SummarizedCargoQualityData.clone)
```
function UtilCargo.SummarizedCargoQualityData.clone(SummarizedCargoQualityData): SummarizedCargoQualityData
```
**Parameters**
* `SummarizedCargoQualityData`
**Returns**
1. `SummarizedCargoQualityData`
### UtilCargo.SummarizedCargoQualityData.passengers[🔗](#$api.engine.util~UtilCargo.SummarizedCargoQualityData.passengers)
```
UtilCargo.SummarizedCargoQualityData.passengers: CargoQualityData
```
### UtilCargo.SummarizedCargoQualityData.cargo[🔗](#$api.engine.util~UtilCargo.SummarizedCargoQualityData.cargo)
```
UtilCargo.SummarizedCargoQualityData.cargo: CargoQualityData
```
### UtilCargo.getCargoQualityDataForLine[🔗](#$api.engine.util~UtilCargo.getCargoQualityDataForLine)
```
function UtilCargo.getCargoQualityDataForLine(lineEntity : Engine.Entity, cargoTypeId : CargoTypeId): UtilCargo.CargoQualityData
```
Get cargo type quality data in a line.
**Parameters**
* `lineEntity` :`Engine.Entity` — line entity
* `cargoTypeId` :`CargoTypeId` — cargo type (passengers allowed)
**Returns**
1. `UtilCargo.CargoQualityData` — data about cargo quality
### UtilCargo.getCargoQualityDataForVehicle[🔗](#$api.engine.util~UtilCargo.getCargoQualityDataForVehicle)
```
function UtilCargo.getCargoQualityDataForVehicle(vehicleEntity : Engine.Entity, cargoTypeId : CargoTypeId): UtilCargo.CargoQualityData
```
Get cargo type quality data in a vehicle.
**Parameters**
* `vehicleEntity` :`Engine.Entity` — vehicle entity
* `cargoTypeId` :`CargoTypeId` — cargo type (passengers allowed)
**Returns**
1. `UtilCargo.CargoQualityData` — data about cargo quality
### UtilCargo.getCargoQualityDataAtStation[🔗](#$api.engine.util~UtilCargo.getCargoQualityDataAtStation)
```
function UtilCargo.getCargoQualityDataAtStation(stationEntity : Engine.Entity, cargoTypeId : CargoTypeId): UtilCargo.CargoQualityData
```
Get all persons waiting at a station plus the number of unhappy ones.
**Parameters**
* `stationEntity` :`Engine.Entity` — station entity
* `cargoTypeId` :`CargoTypeId` — the cargo type (passengers allowed)
**Returns**
1. `UtilCargo.CargoQualityData` — cargo quality data
### UtilCargo.getCargoQualityDataAtStationGroup[🔗](#$api.engine.util~UtilCargo.getCargoQualityDataAtStationGroup)
```
function UtilCargo.getCargoQualityDataAtStationGroup(stationGroupEntity : Engine.Entity, cargoTypeId : CargoTypeId): UtilCargo.CargoQualityData
```
Get all persons waiting at station group plus the number of unhappy ones.
**Parameters**
* `stationGroupEntity` :`Engine.Entity` — station group entity
* `cargoTypeId` :`CargoTypeId` — the cargo type (passengers allowed)
**Returns**
1. `UtilCargo.CargoQualityData` — cargo quality data
### UtilCargo.getCargoQualityDataAtStop[🔗](#$api.engine.util~UtilCargo.getCargoQualityDataAtStop)
```
function UtilCargo.getCargoQualityDataAtStop(lineEntity : Engine.Entity, stopIndex : integer, cargoTypeId : CargoTypeId): UtilCargo.CargoQualityData
```
Get all persons waiting at a certain line stop plus the number of unhappy ones.
**Parameters**
* `lineEntity` :`Engine.Entity` — line entity
* `stopIndex` :`integer` — index of stop
* `cargoTypeId` :`CargoTypeId` — the cargo type (passengers allowed)
**Returns**
1. `UtilCargo.CargoQualityData` — cargo quality data
### UtilCargo.getCargoQualityDataAtTerminal[🔗](#$api.engine.util~UtilCargo.getCargoQualityDataAtTerminal)
```
function UtilCargo.getCargoQualityDataAtTerminal(stationGroupEntity : Engine.Entity, stationTerminal : StationTerminal, cargoTypeId : CargoTypeId): UtilCargo.CargoQualityData
```
Get all persons waiting at a certain terminal plus the number of unhappy ones.
**Parameters**
* `stationGroupEntity` :`Engine.Entity` — station group entity
* `stationTerminal` :`StationTerminal` — the affected station and terminal indices
* `cargoTypeId` :`CargoTypeId` — the cargo type (passengers allowed)
**Returns**
1. `UtilCargo.CargoQualityData` — cargo quality data
### UtilCargo.getCargoQualityDataForStockList[🔗](#$api.engine.util~UtilCargo.getCargoQualityDataForStockList)
```
function UtilCargo.getCargoQualityDataForStockList(stockListEntity : Engine.Entity, cargoTypeId : CargoTypeId): UtilCargo.CargoQualityData
```
Get stock list cargo type quality.
**Parameters**
* `stockListEntity` :`Engine.Entity` — stockList entity
* `cargoTypeId` :`CargoTypeId` — the cargo type (passengers allowed but doesn't make sense)
**Returns**
1. `UtilCargo.CargoQualityData` — cargo quality data
### UtilCargo.getCargoQualityDataForStock[🔗](#$api.engine.util~UtilCargo.getCargoQualityDataForStock)
```
function UtilCargo.getCargoQualityDataForStock(stockListEntity : Engine.Entity, stockId : StockId, cargoTypeId : CargoTypeId): UtilCargo.CargoQualityData
```
Get stock cargo type quality (over all cargo types).
**Parameters**
* `stockListEntity` :`Engine.Entity` — stockList entity
* `stockId` :`StockId` — stock id inside the stock list
* `cargoTypeId` :`CargoTypeId` — the cargo type (passing nil will aggregate over all cargo types)
**Returns**
1. `UtilCargo.CargoQualityData` — cargo quality data
### UtilCargo.getSummarizedCargoQualityDataForStockList[🔗](#$api.engine.util~UtilCargo.getSummarizedCargoQualityDataForStockList)
```
function UtilCargo.getSummarizedCargoQualityDataForStockList(stockListEntity : Engine.Entity): UtilCargo.SummarizedCargoQualityData
```
Get stock list cargo type quality (over all cargo types).
**Parameters**
* `stockListEntity` :`Engine.Entity` — stockList entity
**Returns**
1. `UtilCargo.SummarizedCargoQualityData` — cargo quality data
### UtilCargo.getSummarizedCargoQualityDataForLine[🔗](#$api.engine.util~UtilCargo.getSummarizedCargoQualityDataForLine)
```
function UtilCargo.getSummarizedCargoQualityDataForLine(lineEntity : Engine.Entity): UtilCargo.SummarizedCargoQualityData
```
Get cargo type quality summary.
**Parameters**
* `lineEntity` :`Engine.Entity` — line entity
**Returns**
1. `UtilCargo.SummarizedCargoQualityData` — cargo quality data
### UtilCargo.getSummarizedCargoQualityDataForVehicle[🔗](#$api.engine.util~UtilCargo.getSummarizedCargoQualityDataForVehicle)
```
function UtilCargo.getSummarizedCargoQualityDataForVehicle(vehicleEntity : Engine.Entity): UtilCargo.SummarizedCargoQualityData
```
Get cargo type quality summary.
**Parameters**
* `vehicleEntity` :`Engine.Entity` — vehicle entity
**Returns**
1. `UtilCargo.SummarizedCargoQualityData` — cargo quality data
### UtilCargo.getNumCargoPerTypeInVehicle[🔗](#$api.engine.util~UtilCargo.getNumCargoPerTypeInVehicle)
```
function UtilCargo.getNumCargoPerTypeInVehicle(vehicleEntity : Engine.Entity): {integer}
```
Get total amount of cargo loaded in the vehicle
**Parameters**
* `vehicleEntity` :`Engine.Entity` — vehicle entity
**Returns**
1. `{integer}` — number of cargo items per type
### UtilChart[🔗](#$api.engine.util~UtilChart)
```
global record UtilChart getChartLabel: function(config : ChartConfig, index : integer, abbreviated : boolean): string
setLastValue: function(chartResult : ChartResult, series : integer, value : number)
end
```
### UtilChart.getChartLabel[🔗](#$api.engine.util~UtilChart.getChartLabel)
```
function UtilChart.getChartLabel(config : ChartConfig, index : integer, abbreviated : boolean): string
```
Get label for X axis of date charts.
**Parameters**
* `config` :`ChartConfig` — chart config
* `index` :`integer` — group index of which the label should be returned
* `abbreviated` :`boolean` — if label should be for range (true) or point (false)
**Returns**
1. `string` — chart label string
### UtilChart.setLastValue[🔗](#$api.engine.util~UtilChart.setLastValue)
```
function UtilChart.setLastValue(chartResult : ChartResult, series : integer, value : number)
```
Set the last value for a chart result.
**Parameters**
* `chartResult` :`ChartResult` — chart result containing the series to be updated
* `series` :`integer` — series index of which the last value should be set
* `value` :`number` — value to set as the last value of the series
### UtilConstruction[🔗](#$api.engine.util~UtilConstruction)
```
global record UtilConstruction getNumAndFilledAutoFillSlots: function(entity : Engine.Entity): {integer, integer}
getConstructionEntity: function(depotEntity : Engine.Entity): Engine.Entity
getSlotTypes: function(entity : Engine.Entity): {string}
getConstructionResult: function(constructionResName : ResName, constructionTemplate : integer, parameters : {<any type> : <any type>}): ConstructionResult
getGlobalConstructionParams: function(): {string : number}
getCostMultiplierForYear: function(costMultipliers : {integer : number}, currentYear : integer): number
findSegmentsToDelete: function(constructionEntity : Engine.Entity, keepIndustryRoads : boolean): {Engine.Entity}
end
```
### UtilConstruction.getNumAndFilledAutoFillSlots[🔗](#$api.engine.util~UtilConstruction.getNumAndFilledAutoFillSlots)
```
function UtilConstruction.getNumAndFilledAutoFillSlots(entity : Engine.Entity): {integer, integer}
```
Get total number of auto fill slots and number of filled auto fill slots.
**Parameters**
* `entity` :`Engine.Entity` — construction entity
**Returns**
1. `{integer, integer}` — num filled auto fill slots
### UtilConstruction.getConstructionEntity[🔗](#$api.engine.util~UtilConstruction.getConstructionEntity)
```
function UtilConstruction.getConstructionEntity(depotEntity : Engine.Entity): Engine.Entity
```
Gets construction entity for the entity.
**Parameters**
* `depotEntity` :`Engine.Entity` — the entity for which the containing construction should be fetched
**Returns**
1. `Engine.Entity` — construction entity
### UtilConstruction.getSlotTypes[🔗](#$api.engine.util~UtilConstruction.getSlotTypes)
```
function UtilConstruction.getSlotTypes(entity : Engine.Entity): {string}
```
Get slot types of construction.
**Parameters**
* `entity` :`Engine.Entity` — construction entity
**Returns**
1. `{string}` — slot types
### UtilConstruction.getConstructionResult[🔗](#$api.engine.util~UtilConstruction.getConstructionResult)
```
function UtilConstruction.getConstructionResult(constructionResName : ResName, constructionTemplate : integer, parameters : {<any type> : <any type>}): ConstructionResult
```
Get construction result for a given construction.
**Parameters**
* `constructionResName` :`ResName` — resource name of the construction
* `constructionTemplate` :`integer` — template index
* `parameters` :`{<any type> : <any type>}` — parameters for the updateFn
**Returns**
1. `ConstructionResult` — construction result
### UtilConstruction.getGlobalConstructionParams[🔗](#$api.engine.util~UtilConstruction.getGlobalConstructionParams)
```
function UtilConstruction.getGlobalConstructionParams(): {string : number}
```
Get global construction params
**Returns**
1. `{string : number}` — global construction parameters
### UtilConstruction.getCostMultiplierForYear[🔗](#$api.engine.util~UtilConstruction.getCostMultiplierForYear)
```
function UtilConstruction.getCostMultiplierForYear(costMultipliers : {integer : number}, currentYear : integer): number
```
Get cost multiplier for year
**Parameters**
* `costMultipliers` :`{integer : number}` — cost multipliers by year
* `currentYear` :`integer` — current year
**Returns**
1. `number` — cost multiplier
### UtilConstruction.findSegmentsToDelete[🔗](#$api.engine.util~UtilConstruction.findSegmentsToDelete)
```
function UtilConstruction.findSegmentsToDelete(constructionEntity : Engine.Entity, keepIndustryRoads : boolean): {Engine.Entity}
```
Get street segments to remove when a construction entity is removed
**Parameters**
* `constructionEntity` :`Engine.Entity` — the construction entity we want to find segments for
* `keepIndustryRoads` :`boolean` — (default = false) whether to keep the segments that are built with the industry
**Returns**
1. `{Engine.Entity}` — the street segments to remove
### UtilEmission[🔗](#$api.engine.util~UtilEmission)
```
global record UtilEmission getCurrentEmission: function(entity : Engine.Entity, type : Engine.Component.EmissionGrid.Type): number
getPollutionEmittersInSettlementArea: function(entity : Engine.Entity): {{Engine.Entity, number}}
getNoiseEmittersNearSettlementLandUses: function(entity : Engine.Entity, distance : number, landUseTypes : {LandUseType}): {{Engine.Entity, number}}
end
```
### UtilEmission.getCurrentEmission[🔗](#$api.engine.util~UtilEmission.getCurrentEmission)
```
function UtilEmission.getCurrentEmission(entity : Engine.Entity, type : Engine.Component.EmissionGrid.Type): number
```
Get current emission at entity.
**Parameters**
* `entity` :`Engine.Entity` — the entity with Emission component
* `type` :`Engine.Component.EmissionGrid.Type` — emission type
**Returns**
1. `number` — emission value
### UtilEmission.getPollutionEmittersInSettlementArea[🔗](#$api.engine.util~UtilEmission.getPollutionEmittersInSettlementArea)
```
function UtilEmission.getPollutionEmittersInSettlementArea(entity : Engine.Entity): {{Engine.Entity, number}}
```
Get all pollution emitters in settlement area.
**Parameters**
* `entity` :`Engine.Entity` — the town entity
**Returns**
1. `{{Engine.Entity, number}}` — list of emitters with emission values
### UtilEmission.getNoiseEmittersNearSettlementLandUses[🔗](#$api.engine.util~UtilEmission.getNoiseEmittersNearSettlementLandUses)
```
function UtilEmission.getNoiseEmittersNearSettlementLandUses(entity : Engine.Entity, distance : number, landUseTypes : {LandUseType}): {{Engine.Entity, number}}
```
Get all noise emitters near land uses of a settlement.
**Parameters**
* `entity` :`Engine.Entity` — the settlement entity
* `distance` :`number` — maximum distance
* `landUseTypes` :`{LandUseType}` — land use type filter
**Returns**
1. `{{Engine.Entity, number}}` — list of emitters with emission values
### UtilFinance[🔗](#$api.engine.util~UtilFinance)
```
global record UtilFinance getAccountChart: function(entity : Engine.Entity, config : ChartConfig): ChartResult
getDebtChart: function(entity : Engine.Entity, config : ChartConfig, integer): ChartResult
calculateBalance: function(entities : {Engine.Entity}, begin : integer, end : integer, true : boolean, only : JournalEntry.Maintenance): integer
calculateEarnings: function(playerEntity : Engine.Entity): integer
computeFinanceTable: function(playerEntity : Engine.Entity, config : ChartConfig): FinanceData
getPlayersBalance: function(playerEntity : Engine.Entity): integer
calcIncomeSince: function(current : number, playerEntity : Engine.Entity): number
getLastIncomeTime: function(playerEntity : Engine.Entity): integer
getFirstIncomeTime: function(playerEntity : Engine.Entity): integer
end
```
### UtilFinance.getAccountChart[🔗](#$api.engine.util~UtilFinance.getAccountChart)
```
function UtilFinance.getAccountChart(entity : Engine.Entity, config : ChartConfig): ChartResult
```
Get chart for account (income and costs).
**Parameters**
* `entity` :`Engine.Entity` — entity with account component
* `config` :`ChartConfig` — chart config
**Returns**
1. `ChartResult` — chart result
### UtilFinance.getDebtChart[🔗](#$api.engine.util~UtilFinance.getDebtChart)
```
function UtilFinance.getDebtChart(entity : Engine.Entity, config : ChartConfig, integer): ChartResult
```
Get chart for debts.
**Parameters**
* `entity` :`Engine.Entity` — entity with account component
* `config` :`ChartConfig` — chart config
* `integer`
**Returns**
1. `ChartResult` — chart result
### UtilFinance.calculateBalance[🔗](#$api.engine.util~UtilFinance.calculateBalance)
```
function UtilFinance.calculateBalance(entities : {Engine.Entity}, begin : integer, end : integer, true : boolean, only : JournalEntry.Maintenance): integer
```
Get (summed) balance of entities
**Parameters**
* `entities` :`{Engine.Entity}` — (having an account)
* `begin` :`integer` — time (interval)
* `end` :`integer` — time (interval)
* `true` :`boolean` — if only maintenance/income entries are to be considered
* `only` :`JournalEntry.Maintenance` — consider for given maintenance type (use nil for all)
**Returns**
1. `integer` — (summed) balance over given interval's time
### UtilFinance.calculateEarnings[🔗](#$api.engine.util~UtilFinance.calculateEarnings)
```
function UtilFinance.calculateEarnings(playerEntity : Engine.Entity): integer
```
Get the earnings from beginning of the year to now
**Parameters**
* `playerEntity` :`Engine.Entity` — player entity
**Returns**
1. `integer` — earnings
### UtilFinance.computeFinanceTable[🔗](#$api.engine.util~UtilFinance.computeFinanceTable)
```
function UtilFinance.computeFinanceTable(playerEntity : Engine.Entity, config : ChartConfig): FinanceData
```
Get current state of fincance table.
**Parameters**
* `playerEntity` :`Engine.Entity` — player entity
* `config` :`ChartConfig` — config of chart behind the table
**Returns**
1. `FinanceData` — struct holding all the relevant values
### UtilFinance.getPlayersBalance[🔗](#$api.engine.util~UtilFinance.getPlayersBalance)
```
function UtilFinance.getPlayersBalance(playerEntity : Engine.Entity): integer
```
Get balance of the player's bank account.
**Parameters**
* `playerEntity` :`Engine.Entity` — the player entity
**Returns**
1. `integer` — balance or nil, if player has won the lottery and money is infinite
### UtilFinance.calcIncomeSince[🔗](#$api.engine.util~UtilFinance.calcIncomeSince)
```
function UtilFinance.calcIncomeSince(current : number, playerEntity : Engine.Entity): number
```
The income since the specified time (non-inclusive).
**Parameters**
* `current` :`number` — game time
* `playerEntity` :`Engine.Entity` — the player entity
**Returns**
1. `number` — The income
### UtilFinance.getLastIncomeTime[🔗](#$api.engine.util~UtilFinance.getLastIncomeTime)
```
function UtilFinance.getLastIncomeTime(playerEntity : Engine.Entity): integer
```
The time of the last income.
**Parameters**
* `playerEntity` :`Engine.Entity` — the player entity
**Returns**
1. `integer` — The time of the last income entry
### UtilFinance.getFirstIncomeTime[🔗](#$api.engine.util~UtilFinance.getFirstIncomeTime)
```
function UtilFinance.getFirstIncomeTime(playerEntity : Engine.Entity): integer
```
The time of the first income.
**Parameters**
* `playerEntity` :`Engine.Entity` — the player entity
**Returns**
1. `integer` — The time of the first income entry
### UtilHeadquarters[🔗](#$api.engine.util~UtilHeadquarters)
```
global record UtilHeadquarters getTransportedData: function(): TransportationStats
getCompaniesValue: function(): CompanyValue
end
```
### UtilHeadquarters.getTransportedData[🔗](#$api.engine.util~UtilHeadquarters.getTransportedData)
```
function UtilHeadquarters.getTransportedData(): TransportationStats
```
Obtains the transportation data.
**Returns**
1. `TransportationStats` — some transportation statistics for the company
### UtilHeadquarters.getCompaniesValue[🔗](#$api.engine.util~UtilHeadquarters.getCompaniesValue)
```
function UtilHeadquarters.getCompaniesValue(): CompanyValue
```
Obtains the companie's value
**Returns**
1. `CompanyValue` — company value data
### UtilIndustry[🔗](#$api.engine.util~UtilIndustry)
```
[Expand All] [Collapse All]
global record UtilIndustry record IndustryProductivityInfo producing: boolean
boostFromRule: boolean
boostFromPersonCapacity: boolean
end
getIndustryProductivityInfo: function(entity : Engine.Entity): IndustryProductivityInfo
getClosingIndustries: function(): {{Engine.Entity, ResName}}
getEconomyCargoDependencies: function(economyId : integer): {string : {string : number}}
end
```
### UtilIndustry.IndustryProductivityInfo[🔗](#$api.engine.util~UtilIndustry.IndustryProductivityInfo)
```
record UtilIndustry.IndustryProductivityInfo producing: boolean
boostFromRule: boolean
boostFromPersonCapacity: boolean
end
```
### UtilIndustry.IndustryProductivityInfo.producing[🔗](#$api.engine.util~UtilIndustry.IndustryProductivityInfo.producing)
```
UtilIndustry.IndustryProductivityInfo.producing: boolean
```
### UtilIndustry.IndustryProductivityInfo.boostFromRule[🔗](#$api.engine.util~UtilIndustry.IndustryProductivityInfo.boostFromRule)
```
UtilIndustry.IndustryProductivityInfo.boostFromRule: boolean
```
### UtilIndustry.IndustryProductivityInfo.boostFromPersonCapacity[🔗](#$api.engine.util~UtilIndustry.IndustryProductivityInfo.boostFromPersonCapacity)
```
UtilIndustry.IndustryProductivityInfo.boostFromPersonCapacity: boolean
```
### UtilIndustry.getIndustryProductivityInfo[🔗](#$api.engine.util~UtilIndustry.getIndustryProductivityInfo)
```
function UtilIndustry.getIndustryProductivityInfo(entity : Engine.Entity): IndustryProductivityInfo
```
Get the industry's productivity
**Parameters**
* `entity` :`Engine.Entity` — the industry entity
**Returns**
1. `IndustryProductivityInfo` — productivity info
### UtilIndustry.getClosingIndustries[🔗](#$api.engine.util~UtilIndustry.getClosingIndustries)
```
function UtilIndustry.getClosingIndustries(): {{Engine.Entity, ResName}}
```
Get list of industries that are closing
**Returns**
1. `{{Engine.Entity, ResName}}` — list of industry entities and their resource names
### UtilIndustry.getEconomyCargoDependencies[🔗](#$api.engine.util~UtilIndustry.getEconomyCargoDependencies)
```
function UtilIndustry.getEconomyCargoDependencies(economyId : integer): {string : {string : number}}
```
Get the cargo dependencies of an economy
**Parameters**
* `economyId` :`integer` — the economy id
**Returns**
1. `{string : {string : number}}` — A map from cargoTag to a map of industryTag to count
### UtilLine[🔗](#$api.engine.util~UtilLine)
```
[Expand All] [Collapse All]
global record UtilLine record LineCapacityUsage used: number
capacity: number
end
record PathProblemLocation edgeIndex: integer
node: NodeId
nodePosition: Vec3f
okModes: {TransportMode : boolean}
relaxedModes: {TransportMode : boolean}
allowedModes: {TransportMode : boolean}
end
record TerminalCapacityUsage equals: function(TerminalCapacityUsage, TerminalCapacityUsage): boolean
used: number
capacity: number
end
record StopState empty: boolean
noPath: boolean
noPathFromAlternative: {integer, PathProblemLocation}
noPathToAlternative: {integer, PathProblemLocation}
duplicateStop: boolean
incompatibleStop: boolean
noPathLocation: PathProblemLocation
end
getLineCapacityUsages: function(line : Engine.Entity, allCapacities : boolean): {CargoTypeId : LineCapacityUsage}
calcLineStationThroughput: function(lineEntity : Engine.Entity): integer
getMaxFrequency: function(lineEntity : Engine.Entity): number
getDetailedLineProblems: function(lineEntity : Engine.Entity): {{StopState}}
getLineProblems: function(): {{Engine.Entity, integer, PathProblemLocation}}
getLineStationProblems: function(): {{Engine.Entity, Engine.Entity, LineStationProblem}}
isLineCompatibleWithCarrier: function(lineEntity : Engine.Entity, carrier : Carrier, distinguishTramFromRoad : boolean): boolean
isLineCompatibleWithAnyCarrier: function(lineEntity : Engine.Entity, carriers : {Carrier}, distinguishTramFromRoad : boolean): boolean
supportsReservation: function(lineEntity : Engine.Entity): boolean
getLineIssues: function(lineEntity : Engine.Entity, allIssues : boolean): {LineIssue}
getLinesIssues: function(playerEntity : Engine.Entity, allIssues : boolean): {Engine.Entity : {LineIssue}}
getFailedPathReason: function(vehicle : Engine.Entity, line : Engine.Entity, fullLine : boolean): Failure
getNoRoadConnectionProblems: function(): {Engine.Entity}
end
```
### UtilLine.LineCapacityUsage[🔗](#$api.engine.util~UtilLine.LineCapacityUsage)
```
record UtilLine.LineCapacityUsage used: number
capacity: number
end
```
### UtilLine.LineCapacityUsage.used[🔗](#$api.engine.util~UtilLine.LineCapacityUsage.used)
```
UtilLine.LineCapacityUsage.used: number
```
Currently used capacity
### UtilLine.LineCapacityUsage.capacity[🔗](#$api.engine.util~UtilLine.LineCapacityUsage.capacity)
```
UtilLine.LineCapacityUsage.capacity: number
```
Total capacity
### UtilLine.PathProblemLocation[🔗](#$api.engine.util~UtilLine.PathProblemLocation)
```
record UtilLine.PathProblemLocation edgeIndex: integer
node: NodeId
nodePosition: Vec3f
okModes: {TransportMode : boolean}
relaxedModes: {TransportMode : boolean}
allowedModes: {TransportMode : boolean}
end
```
### UtilLine.PathProblemLocation.edgeIndex[🔗](#$api.engine.util~UtilLine.PathProblemLocation.edgeIndex)
```
UtilLine.PathProblemLocation.edgeIndex: integer
```
### UtilLine.PathProblemLocation.node[🔗](#$api.engine.util~UtilLine.PathProblemLocation.node)
```
UtilLine.PathProblemLocation.node: NodeId
```
### UtilLine.PathProblemLocation.nodePosition[🔗](#$api.engine.util~UtilLine.PathProblemLocation.nodePosition)
```
UtilLine.PathProblemLocation.nodePosition: Vec3f
```
### UtilLine.PathProblemLocation.okModes[🔗](#$api.engine.util~UtilLine.PathProblemLocation.okModes)
```
UtilLine.PathProblemLocation.okModes: {TransportMode : boolean}
```
compatible transport modes present on the last compatible edge (e.g. ELECTRIC\_TRAIN)
### UtilLine.PathProblemLocation.relaxedModes[🔗](#$api.engine.util~UtilLine.PathProblemLocation.relaxedModes)
```
UtilLine.PathProblemLocation.relaxedModes: {TransportMode : boolean}
```
compatible relaxed transport modes on the first incompatible edge.
Example 1: okModes[ELECTRIC\_TRAIN], relaxedModes[TRAIN] -> relaxation allowed the use of non-electric train, indicating missing catenaries
Example 2: okModes[TRAM], relaxedModes[ROAD] -> relaxation allowed the use of road instead of tram, indicating missing tram lanes
note that this can never overlap with okModes (otherwise there would not be a problem here)
### UtilLine.PathProblemLocation.allowedModes[🔗](#$api.engine.util~UtilLine.PathProblemLocation.allowedModes)
```
UtilLine.PathProblemLocation.allowedModes: {TransportMode : boolean}
```
Allowed modes for the line / vehicle in general
### UtilLine.TerminalCapacityUsage[🔗](#$api.engine.util~UtilLine.TerminalCapacityUsage)
```
record UtilLine.TerminalCapacityUsage equals: function(TerminalCapacityUsage, TerminalCapacityUsage): boolean
used: number
capacity: number
end
```
### UtilLine.TerminalCapacityUsage.equals[🔗](#$api.engine.util~UtilLine.TerminalCapacityUsage.equals)
```
function UtilLine.TerminalCapacityUsage.equals(TerminalCapacityUsage, TerminalCapacityUsage): boolean
```
**Parameters**
* `TerminalCapacityUsage`
* `TerminalCapacityUsage`
**Returns**
1. `boolean`
### UtilLine.TerminalCapacityUsage.used[🔗](#$api.engine.util~UtilLine.TerminalCapacityUsage.used)
```
UtilLine.TerminalCapacityUsage.used: number
```
Currently used capacity
### UtilLine.TerminalCapacityUsage.capacity[🔗](#$api.engine.util~UtilLine.TerminalCapacityUsage.capacity)
```
UtilLine.TerminalCapacityUsage.capacity: number
```
Total capacity
### UtilLine.StopState[🔗](#$api.engine.util~UtilLine.StopState)
```
record UtilLine.StopState empty: boolean
noPath: boolean
noPathFromAlternative: {integer, PathProblemLocation}
noPathToAlternative: {integer, PathProblemLocation}
duplicateStop: boolean
incompatibleStop: boolean
noPathLocation: PathProblemLocation
end
```
Information about the problem of a line.
### UtilLine.StopState.empty[🔗](#$api.engine.util~UtilLine.StopState.empty)
```
UtilLine.StopState.empty: boolean
```
No vehicles and less than 2 stops
### UtilLine.StopState.noPath[🔗](#$api.engine.util~UtilLine.StopState.noPath)
```
UtilLine.StopState.noPath: boolean
```
No path between stops
### UtilLine.StopState.noPathFromAlternative[🔗](#$api.engine.util~UtilLine.StopState.noPathFromAlternative)
```
UtilLine.StopState.noPathFromAlternative: {integer, PathProblemLocation}
```
No path from an alternative stop {flattenedTerminalIndex, optional problem location}
### UtilLine.StopState.noPathToAlternative[🔗](#$api.engine.util~UtilLine.StopState.noPathToAlternative)
```
UtilLine.StopState.noPathToAlternative: {integer, PathProblemLocation}
```
No path to an alternative stop {flattenedTerminalIndex, optional problem location}
### UtilLine.StopState.duplicateStop[🔗](#$api.engine.util~UtilLine.StopState.duplicateStop)
```
UtilLine.StopState.duplicateStop: boolean
```
Stop is a duplicate
### UtilLine.StopState.incompatibleStop[🔗](#$api.engine.util~UtilLine.StopState.incompatibleStop)
```
UtilLine.StopState.incompatibleStop: boolean
```
Stop is incompatible with the line's transport mode
### UtilLine.StopState.noPathLocation[🔗](#$api.engine.util~UtilLine.StopState.noPathLocation)
```
UtilLine.StopState.noPathLocation: PathProblemLocation
```
Optional problem location in case of noPath
### UtilLine.getLineCapacityUsages[🔗](#$api.engine.util~UtilLine.getLineCapacityUsages)
```
function UtilLine.getLineCapacityUsages(line : Engine.Entity, allCapacities : boolean): {CargoTypeId : LineCapacityUsage}
```
Get line capacity usages.
**Parameters**
* `line` :`Engine.Entity` — line entity
* `allCapacities` :`boolean` — whether to return all capacities or the capacities for the vehicles current load config
**Returns**
1. `{CargoTypeId : LineCapacityUsage}` — map of cargo type to capacity usage
### UtilLine.calcLineStationThroughput[🔗](#$api.engine.util~UtilLine.calcLineStationThroughput)
```
function UtilLine.calcLineStationThroughput(lineEntity : Engine.Entity): integer
```
Calc line throughput
**Parameters**
* `lineEntity` :`Engine.Entity` — line entity
**Returns**
1. `integer` — throughput value
### UtilLine.getMaxFrequency[🔗](#$api.engine.util~UtilLine.getMaxFrequency)
```
function UtilLine.getMaxFrequency(lineEntity : Engine.Entity): number
```
Get line max frequency
**Parameters**
* `lineEntity` :`Engine.Entity` — line entity
**Returns**
1. `number` — max frequency
### UtilLine.getDetailedLineProblems[🔗](#$api.engine.util~UtilLine.getDetailedLineProblems)
```
function UtilLine.getDetailedLineProblems(lineEntity : Engine.Entity): {{StopState}}
```
Get lines with detailed problems per stop
**Parameters**
* `lineEntity` :`Engine.Entity` — line entity
**Returns**
1. `{{StopState}}` — list of stop problems
### UtilLine.getLineProblems[🔗](#$api.engine.util~UtilLine.getLineProblems)
```
function UtilLine.getLineProblems(): {{Engine.Entity, integer, PathProblemLocation}}
```
Get lines with problems
**Returns**
1. `{{Engine.Entity, integer, PathProblemLocation}}` — list of {line entity, problem type, optional info about 1st problem and its location}
### UtilLine.getLineStationProblems[🔗](#$api.engine.util~UtilLine.getLineStationProblems)
```
function UtilLine.getLineStationProblems(): {{Engine.Entity, Engine.Entity, LineStationProblem}}
```
Get station problems with lines
**Returns**
1. `{{Engine.Entity, Engine.Entity, LineStationProblem}}` — list of line entity, station group entity and problem type
### UtilLine.isLineCompatibleWithCarrier[🔗](#$api.engine.util~UtilLine.isLineCompatibleWithCarrier)
```
function UtilLine.isLineCompatibleWithCarrier(lineEntity : Engine.Entity, carrier : Carrier, distinguishTramFromRoad : boolean): boolean
```
Check if line is ok with provided carrier
**Parameters**
* `lineEntity` :`Engine.Entity` — line entity
* `carrier` :`Carrier` — carrier type
* `distinguishTramFromRoad` :`boolean` — if tram should not be counted as road
**Returns**
1. `boolean` — true if the line is compatible with the specified carrier
### UtilLine.isLineCompatibleWithAnyCarrier[🔗](#$api.engine.util~UtilLine.isLineCompatibleWithAnyCarrier)
```
function UtilLine.isLineCompatibleWithAnyCarrier(lineEntity : Engine.Entity, carriers : {Carrier}, distinguishTramFromRoad : boolean): boolean
```
Check if line is ok with any of provided carriers
**Parameters**
* `lineEntity` :`Engine.Entity` — line entity
* `carriers` :`{Carrier}` — list of carrier types
* `distinguishTramFromRoad` :`boolean` — if tram should not be counted as road
**Returns**
1. `boolean` — true if the line is compatible with any of the specified carriers
### UtilLine.supportsReservation[🔗](#$api.engine.util~UtilLine.supportsReservation)
```
function UtilLine.supportsReservation(lineEntity : Engine.Entity): boolean
```
Check if line supports reservations
**Parameters**
* `lineEntity` :`Engine.Entity` — line entity
**Returns**
1. `boolean` — whether line supports reservations
### UtilLine.getLineIssues[🔗](#$api.engine.util~UtilLine.getLineIssues)
```
function UtilLine.getLineIssues(lineEntity : Engine.Entity, allIssues : boolean): {LineIssue}
```
Get line configuration problems for the line
**Parameters**
* `lineEntity` :`Engine.Entity` — line entity
* `allIssues` :`boolean` — whether to return all issues
**Returns**
1. `{LineIssue}` — all line issues of the line
### UtilLine.getLinesIssues[🔗](#$api.engine.util~UtilLine.getLinesIssues)
```
function UtilLine.getLinesIssues(playerEntity : Engine.Entity, allIssues : boolean): {Engine.Entity : {LineIssue}}
```
Get line configuration problems for the player lines
**Parameters**
* `playerEntity` :`Engine.Entity` — player entity
* `allIssues` :`boolean` — whether to return all issues
**Returns**
1. `{Engine.Entity : {LineIssue}}` — all line issues of the lines belonging to the player
### UtilLine.getFailedPathReason[🔗](#$api.engine.util~UtilLine.getFailedPathReason)
```
function UtilLine.getFailedPathReason(vehicle : Engine.Entity, line : Engine.Entity, fullLine : boolean): Failure
```
Get the reason for failed pathfinding search
**Parameters**
* `vehicle` :`Engine.Entity` — vehicle entity
* `line` :`Engine.Entity` — line entity
* `fullLine` :`boolean` — whether to check full line
**Returns**
1. `Failure` — failure reason
### UtilLine.getNoRoadConnectionProblems[🔗](#$api.engine.util~UtilLine.getNoRoadConnectionProblems)
```
function UtilLine.getNoRoadConnectionProblems(): {Engine.Entity}
```
Get nodes (construction entities) without any road connection
**Returns**
1. `{Engine.Entity}` — list of node entities
### UtilLogbook[🔗](#$api.engine.util~UtilLogbook)
```
global record UtilLogbook getLogValuePerYear: function(entity : Engine.Entity, logName : string): integer
getLogValueMostRecent: function(entity : Engine.Entity, logName : string): integer
getLogValueOldest: function(entity : Engine.Entity, logName : string): integer
logValue: function(entity : Engine.Entity, logName : string, value : integer)
getChart: function(logbookEntity : Engine.Entity, logNames : {string}, xMin : number, xMax : number, yMin : number, yMax : number, ChartConfig : ChartConfig): ChartResult
getChartDiff: function(entity : Engine.Entity, logNames : {string}, config : ChartConfig): ChartResult
end
```
### UtilLogbook.getLogValuePerYear[🔗](#$api.engine.util~UtilLogbook.getLogValuePerYear)
```
function UtilLogbook.getLogValuePerYear(entity : Engine.Entity, logName : string): integer
```
Get log value difference in the last year for cargo type
**Parameters**
* `entity` :`Engine.Entity` — entity with logbook component
* `logName` :`string` — log entry name
**Returns**
1. `integer` — log value difference in the last year for cargo type
### UtilLogbook.getLogValueMostRecent[🔗](#$api.engine.util~UtilLogbook.getLogValueMostRecent)
```
function UtilLogbook.getLogValueMostRecent(entity : Engine.Entity, logName : string): integer
```
Get most recent log value
**Parameters**
* `entity` :`Engine.Entity` — entity with logbook component
* `logName` :`string` — log entry name
**Returns**
1. `integer` — log value difference in the last year for cargo type
### UtilLogbook.getLogValueOldest[🔗](#$api.engine.util~UtilLogbook.getLogValueOldest)
```
function UtilLogbook.getLogValueOldest(entity : Engine.Entity, logName : string): integer
```
Get oldest log value
**Parameters**
* `entity` :`Engine.Entity` — entity with logbook component
* `logName` :`string` — log entry name
**Returns**
1. `integer` — oldest log value
### UtilLogbook.logValue[🔗](#$api.engine.util~UtilLogbook.logValue)
```
function UtilLogbook.logValue(entity : Engine.Entity, logName : string, value : integer)
```
Log a value
**Parameters**
* `entity` :`Engine.Entity` — entity with logbook component
* `logName` :`string` — log entry name
* `value` :`integer` — value to log
### UtilLogbook.getChart[🔗](#$api.engine.util~UtilLogbook.getChart)
```
function UtilLogbook.getChart(logbookEntity : Engine.Entity, logNames : {string}, xMin : number, xMax : number, yMin : number, yMax : number, ChartConfig : ChartConfig): ChartResult
```
Get chart for logbook
**Parameters**
* `logbookEntity` :`Engine.Entity` — entity with logbook component
* `logNames` :`{string}` — log types
* `xMin` :`number` — Starting value of x-axis (automatically reduced to the lowest x in the data)
* `xMax` :`number` — End value of x-axis (automatically increased to the highest x in the data)
* `yMin` :`number` — Starting value of y-axis (automatically reduced to the lowest y in the data)
* `yMax` :`number` — End value of y-axis (automatically increased to the highest y in the data)
* `ChartConfig` :`ChartConfig` — config of the chart to get
**Returns**
1. `ChartResult` — chart result
### UtilLogbook.getChartDiff[🔗](#$api.engine.util~UtilLogbook.getChartDiff)
```
function UtilLogbook.getChartDiff(entity : Engine.Entity, logNames : {string}, config : ChartConfig): ChartResult
```
Get diff chart for logbooks
**Parameters**
* `entity` :`Engine.Entity` — entity with logbook component
* `logNames` :`{string}` — log types
* `config` :`ChartConfig` — chart config
**Returns**
1. `ChartResult` — chart result
### UtilMaintenance[🔗](#$api.engine.util~UtilMaintenance)
```
global record UtilMaintenance calcMaintenanceForStationGroup: function(stationGroupEntity : Engine.Entity): integer
calcMaintenanceForSubconstruction: function(subconstructionEntity : Engine.Entity): integer
end
```
### UtilMaintenance.calcMaintenanceForStationGroup[🔗](#$api.engine.util~UtilMaintenance.calcMaintenanceForStationGroup)
```
function UtilMaintenance.calcMaintenanceForStationGroup(stationGroupEntity : Engine.Entity): integer
```
Calculate maintenance cost for a station group
**Parameters**
* `stationGroupEntity` :`Engine.Entity` — station group entity
**Returns**
1. `integer` — maintenance cost
### UtilMaintenance.calcMaintenanceForSubconstruction[🔗](#$api.engine.util~UtilMaintenance.calcMaintenanceForSubconstruction)
```
function UtilMaintenance.calcMaintenanceForSubconstruction(subconstructionEntity : Engine.Entity): integer
```
Calculate maintenance cost for a subconstruction
**Parameters**
* `subconstructionEntity` :`Engine.Entity` — subconstruction entity
**Returns**
1. `integer` — maintenance cost
### UtilOctree[🔗](#$api.engine.util~UtilOctree)
```
global record UtilOctree findEntitiesInCircle: function(center : Vec2f, radius : number, componentType : Engine.ComponentType): {Engine.Entity}
findTransportNetworkNodesInCircle: function(center : Vec2f, radius : number): {NodeId}
areWaypointsOnLine: function(waypoints : {Vec2f}, lineEntity : Engine.Entity, tolerance : number): boolean
end
```
### UtilOctree.findEntitiesInCircle[🔗](#$api.engine.util~UtilOctree.findEntitiesInCircle)
```
function UtilOctree.findEntitiesInCircle(center : Vec2f, radius : number, componentType : Engine.ComponentType): {Engine.Entity}
```
Get entities in given radius and component type
**Parameters**
* `center` :`Vec2f` — center position
* `radius` :`number` — search radius
* `componentType` :`Engine.ComponentType` — component type
**Returns**
1. `{Engine.Entity}` — list of entities
### UtilOctree.findTransportNetworkNodesInCircle[🔗](#$api.engine.util~UtilOctree.findTransportNetworkNodesInCircle)
```
function UtilOctree.findTransportNetworkNodesInCircle(center : Vec2f, radius : number): {NodeId}
```
Get transport network nodes in given radius
**Parameters**
* `center` :`Vec2f` — center position
* `radius` :`number` — search radius
**Returns**
1. `{NodeId}` — list of node IDs
### UtilOctree.areWaypointsOnLine[🔗](#$api.engine.util~UtilOctree.areWaypointsOnLine)
```
function UtilOctree.areWaypointsOnLine(waypoints : {Vec2f}, lineEntity : Engine.Entity, tolerance : number): boolean
```
Check if waypoints are on a line
**Parameters**
* `waypoints` :`{Vec2f}` — list of positions
* `lineEntity` :`Engine.Entity` — the line entity
* `tolerance` :`number` — distance tolerance
**Returns**
1. `boolean` — true if waypoints are on line
### UtilParallelStrip[🔗](#$api.engine.util~UtilParallelStrip)
```
[Expand All] [Collapse All]
global record UtilParallelStrip record StripInfo carrier: Carrier
edgeType: BaseEdgeType
edgeTypeIndex: integer
end
getStripInfo: function(entity : Engine.Entity): StripInfo
isBridge: function(entity : Engine.Entity): boolean
isTunnel: function(entity : Engine.Entity): boolean
end
```
### UtilParallelStrip.StripInfo[🔗](#$api.engine.util~UtilParallelStrip.StripInfo)
```
record UtilParallelStrip.StripInfo carrier: Carrier
edgeType: BaseEdgeType
edgeTypeIndex: integer
end
```
### UtilParallelStrip.StripInfo.carrier[🔗](#$api.engine.util~UtilParallelStrip.StripInfo.carrier)
```
UtilParallelStrip.StripInfo.carrier: Carrier
```
### UtilParallelStrip.StripInfo.edgeType[🔗](#$api.engine.util~UtilParallelStrip.StripInfo.edgeType)
```
UtilParallelStrip.StripInfo.edgeType: BaseEdgeType
```
### UtilParallelStrip.StripInfo.edgeTypeIndex[🔗](#$api.engine.util~UtilParallelStrip.StripInfo.edgeTypeIndex)
```
UtilParallelStrip.StripInfo.edgeTypeIndex: integer
```
### UtilParallelStrip.getStripInfo[🔗](#$api.engine.util~UtilParallelStrip.getStripInfo)
```
function UtilParallelStrip.getStripInfo(entity : Engine.Entity): StripInfo
```
Get strip information for a parallel strip entity
**Parameters**
* `entity` :`Engine.Entity` — parallel strip entity
**Returns**
1. `StripInfo` — strip information
### UtilParallelStrip.isBridge[🔗](#$api.engine.util~UtilParallelStrip.isBridge)
```
function UtilParallelStrip.isBridge(entity : Engine.Entity): boolean
```
Check if entity is a bridge
**Parameters**
* `entity` :`Engine.Entity` — parallel strip entity
**Returns**
1. `boolean` — true if bridge
### UtilParallelStrip.isTunnel[🔗](#$api.engine.util~UtilParallelStrip.isTunnel)
```
function UtilParallelStrip.isTunnel(entity : Engine.Entity): boolean
```
Check if entity is a tunnel
**Parameters**
* `entity` :`Engine.Entity` — parallel strip entity
**Returns**
1. `boolean` — true if tunnel
### UtilPathfinding[🔗](#$api.engine.util~UtilPathfinding)
```
[Expand All] [Collapse All]
global record UtilPathfinding record EdgeIdDirAndLength edgeId: EdgeId
dir: boolean
length: number
new: function(EdgeId, boolean, number): EdgeIdDirAndLength
end
record EdgeIdDir edgeId: EdgeId
dir: boolean
new: function(EdgeId, boolean): EdgeIdDir
end
findPath: function(startingEdgesAndLengths : {EdgeIdDirAndLength}, destinationNodes : {NodeId}, transportModeSet : {TransportMode}, maxLength : number): {{EdgeId, boolean}}
findPathNodeToNode: function(startNodes : {NodeId}, destinationNodes : {NodeId}, transportModeSet : {TransportMode}): {{EdgeId, boolean}}
getTargetsByLandUse: function(): {<any type> : <any type>}
findDubinsPath: function(p0 : Vec3f, t0 : Vec3f, p1 : Vec3f, t1 : Vec3f, turnRadius : number): {{EdgeGeometry, boolean}}
end
```
### UtilPathfinding.EdgeIdDirAndLength[🔗](#$api.engine.util~UtilPathfinding.EdgeIdDirAndLength)
```
record UtilPathfinding.EdgeIdDirAndLength edgeId: EdgeId
dir: boolean
length: number
new: function(EdgeId, boolean, number): EdgeIdDirAndLength
end
```
### UtilPathfinding.EdgeIdDirAndLength.edgeId[🔗](#$api.engine.util~UtilPathfinding.EdgeIdDirAndLength.edgeId)
```
UtilPathfinding.EdgeIdDirAndLength.edgeId: EdgeId
```
Edge ID
### UtilPathfinding.EdgeIdDirAndLength.dir[🔗](#$api.engine.util~UtilPathfinding.EdgeIdDirAndLength.dir)
```
UtilPathfinding.EdgeIdDirAndLength.dir: boolean
```
Direction
### UtilPathfinding.EdgeIdDirAndLength.length[🔗](#$api.engine.util~UtilPathfinding.EdgeIdDirAndLength.length)
```
UtilPathfinding.EdgeIdDirAndLength.length: number
```
Length
### UtilPathfinding.EdgeIdDirAndLength.new[🔗](#$api.engine.util~UtilPathfinding.EdgeIdDirAndLength.new)
```
function UtilPathfinding.EdgeIdDirAndLength.new(EdgeId, boolean, number): EdgeIdDirAndLength
```
Generates a new item.
**Parameters**
* `EdgeId`
* `boolean`
* `number`
**Returns**
1. `EdgeIdDirAndLength`
### UtilPathfinding.EdgeIdDir[🔗](#$api.engine.util~UtilPathfinding.EdgeIdDir)
```
record UtilPathfinding.EdgeIdDir edgeId: EdgeId
dir: boolean
new: function(EdgeId, boolean): EdgeIdDir
end
```
### UtilPathfinding.EdgeIdDir.edgeId[🔗](#$api.engine.util~UtilPathfinding.EdgeIdDir.edgeId)
```
UtilPathfinding.EdgeIdDir.edgeId: EdgeId
```
Edge ID
### UtilPathfinding.EdgeIdDir.dir[🔗](#$api.engine.util~UtilPathfinding.EdgeIdDir.dir)
```
UtilPathfinding.EdgeIdDir.dir: boolean
```
Direction
### UtilPathfinding.EdgeIdDir.new[🔗](#$api.engine.util~UtilPathfinding.EdgeIdDir.new)
```
function UtilPathfinding.EdgeIdDir.new(EdgeId, boolean): EdgeIdDir
```
Generates a new item.
**Parameters**
* `EdgeId`
* `boolean`
**Returns**
1. `EdgeIdDir`
### UtilPathfinding.findPath[🔗](#$api.engine.util~UtilPathfinding.findPath)
```
function UtilPathfinding.findPath(startingEdgesAndLengths : {EdgeIdDirAndLength}, destinationNodes : {NodeId}, transportModeSet : {TransportMode}, maxLength : number): {{EdgeId, boolean}}
```
Find a path between starting edges and end destination nodes, using a given set of transport modes.
**Parameters**
* `startingEdgesAndLengths` :`{EdgeIdDirAndLength}` — Vector of EdgeIdDirAndLength
* `destinationNodes` :`{NodeId}` — Vector of NodeId
* `transportModeSet` :`{TransportMode}` — Vector of TransportMode
* `maxLength` :`number` — maximum path length
**Returns**
1. `{{EdgeId, boolean}}` — a vector with pairs of EdgeId and bool values
### UtilPathfinding.findPathNodeToNode[🔗](#$api.engine.util~UtilPathfinding.findPathNodeToNode)
```
function UtilPathfinding.findPathNodeToNode(startNodes : {NodeId}, destinationNodes : {NodeId}, transportModeSet : {TransportMode}): {{EdgeId, boolean}}
```
Find a path between starting nodes and end destination nodes, using a given set of transport modes.
**Parameters**
* `startNodes` :`{NodeId}` — Vector of NodeId
* `destinationNodes` :`{NodeId}` — Vector of NodeId
* `transportModeSet` :`{TransportMode}` — Vector of TransportMode
**Returns**
1. `{{EdgeId, boolean}}` — a vector with pairs of EdgeId and bool values
### UtilPathfinding.getTargetsByLandUse[🔗](#$api.engine.util~UtilPathfinding.getTargetsByLandUse)
```
function UtilPathfinding.getTargetsByLandUse(): {<any type> : <any type>}
```
**Returns**
1. `{<any type> : <any type>}`
### UtilPathfinding.findDubinsPath[🔗](#$api.engine.util~UtilPathfinding.findDubinsPath)
```
function UtilPathfinding.findDubinsPath(p0 : Vec3f, t0 : Vec3f, p1 : Vec3f, t1 : Vec3f, turnRadius : number): {{EdgeGeometry, boolean}}
```
Find a Dubins path between two points with directions
**Parameters**
* `p0` :`Vec3f` — first point
* `t0` :`Vec3f` — tangent at p0
* `p1` :`Vec3f` — second point
* `t1` :`Vec3f` — tangent at p1
* `turnRadius` :`number` — maximal turn radius
**Returns**
1. `{{EdgeGeometry, boolean}}` — A list of EdgeGeometries and direction
### UtilProposal[🔗](#$api.engine.util~UtilProposal)
```
global record UtilProposal makeProposalData: function(Proposal, Context): ProposalData
makeIndustrySpawnProposal: function(industryTypeTag : string, townEntity : Engine.Entity): Proposal
makeSegmentsRemoveProposal: function(segmentsToRemove : {Engine.Entity}): Proposal
createProposalRemove: function(entity : Engine.Entity, context : Context): Proposal
createProposalReplaceConstruction: function(entity : Engine.Entity, params : {<any type> : <any type>}, newResName : ResName): Proposal
createIndustryProposal: function(seed : string, industryRectangle : IndustryInfo, context : Context): Proposal
createBridgeOrTunnelProposal: function(parallelStripEntity : Engine.Entity, newTypeIndex : integer): Proposal
createDoubleSlipSwitchProposal: function(entity : Engine.Entity, doubleSlipSwitch : boolean): Proposal
createTrafficLightProposal: function(entity : Engine.Entity, trafficLightConfig : Engine.Component.TrafficLightConfig, trafficLightPreference : TrafficLightPreference): Proposal
getBridgeOrTunnelRelatedRevisions: function(parallelStripEntity : Engine.Entity): {Engine.Entity : Engine.Revision}
didBridgeOrTunnelRelatedRevisionsChange: function(parallelStripEntity : Engine.Entity, revisions : {Engine.Entity : Engine.Revision}): boolean
makeReforestationProposal: function(seed : integer, numTilesToUpdate : integer, maxTreesPerTile : integer): Proposal
refreshConstruction: function(entity : Engine.Entity, constructionFilepath : string): Proposal
replaceSegment: function(entity : Engine.Entity, streetTemplate : ResName): Proposal
checkProposalConnectsNodes: function(startNode : Engine.Entity, startEdge : Engine.Entity, targetNode : Engine.Entity, streetProposal : Proposal.StreetProposal, isApply : boolean, maxDepth : number): boolean
makeIndustryExtendProposal: function(industry : Engine.Entity, trySlots : integer, numExtendSlots : integer): {Proposal, {integer}}
createSubconstructionLotList: function(Proposal.Subconstruction, Mat4f): Engine.Component.LotList
getConstructionArea: function(proposal : Proposal): number
end
```
### UtilProposal.makeProposalData[🔗](#$api.engine.util~UtilProposal.makeProposalData)
```
function UtilProposal.makeProposalData(Proposal, Context): ProposalData
```
**Parameters**
* `Proposal`
* `Context`
**Returns**
1. `ProposalData`
### UtilProposal.makeIndustrySpawnProposal[🔗](#$api.engine.util~UtilProposal.makeIndustrySpawnProposal)
```
function UtilProposal.makeIndustrySpawnProposal(industryTypeTag : string, townEntity : Engine.Entity): Proposal
```
Tries to generate a proposal for randomly placing an industry.
**Parameters**
* `industryTypeTag` :`string` — The type of the industry
* `townEntity` :`Engine.Entity` — the town designating the target voronoi cell (or nil to spawn anywhere in the world)
**Returns**
1. `Proposal` — the generated proposal, or nil
### UtilProposal.makeSegmentsRemoveProposal[🔗](#$api.engine.util~UtilProposal.makeSegmentsRemoveProposal)
```
function UtilProposal.makeSegmentsRemoveProposal(segmentsToRemove : {Engine.Entity}): Proposal
```
Makes a proposal to remove segments
**Parameters**
* `segmentsToRemove` :`{Engine.Entity}` — list of segments to remove
**Returns**
1. `Proposal` — the generated proposal
### UtilProposal.createProposalRemove[🔗](#$api.engine.util~UtilProposal.createProposalRemove)
```
function UtilProposal.createProposalRemove(entity : Engine.Entity, context : Context): Proposal
```
Tries to generate a proposal to remove a construction
**Parameters**
* `entity` :`Engine.Entity` — the entity to remove
* `context` :`Context` — construction context
**Returns**
1. `Proposal` — the generated proposal, or nil
### UtilProposal.createProposalReplaceConstruction[🔗](#$api.engine.util~UtilProposal.createProposalReplaceConstruction)
```
function UtilProposal.createProposalReplaceConstruction(entity : Engine.Entity, params : {<any type> : <any type>}, newResName : ResName): Proposal
```
Replaces an existing construction with a new one
**Parameters**
* `entity` :`Engine.Entity` — the entity to replace
* `params` :`{<any type> : <any type>}` — parameters for the new construction
* `newResName` :`ResName` — resource name of the new construction (if nil, the same as the old one is used)
**Returns**
1. `Proposal` — the generated proposal, or nil
### UtilProposal.createIndustryProposal[🔗](#$api.engine.util~UtilProposal.createIndustryProposal)
```
function UtilProposal.createIndustryProposal(seed : string, industryRectangle : IndustryInfo, context : Context): Proposal
```
Tries to generate a proposal to build an industry
**Parameters**
* `seed` :`string` — random seed
* `industryRectangle` :`IndustryInfo` — industry rectangle data
* `context` :`Context` — construction context
**Returns**
1. `Proposal` — the generated proposal, or nil
### UtilProposal.createBridgeOrTunnelProposal[🔗](#$api.engine.util~UtilProposal.createBridgeOrTunnelProposal)
```
function UtilProposal.createBridgeOrTunnelProposal(parallelStripEntity : Engine.Entity, newTypeIndex : integer): Proposal
```
Creates a bridge or tunnel proposal for changing the type of a parallel strip entity.
**Parameters**
* `parallelStripEntity` :`Engine.Entity` — parallel strip entity
* `newTypeIndex` :`integer` — new resource type index for bridge or tunnel
**Returns**
1. `Proposal` — the generated proposal
### UtilProposal.createDoubleSlipSwitchProposal[🔗](#$api.engine.util~UtilProposal.createDoubleSlipSwitchProposal)
```
function UtilProposal.createDoubleSlipSwitchProposal(entity : Engine.Entity, doubleSlipSwitch : boolean): Proposal
```
Creates a double slip switch proposal for changing the switch type of a base node configuration entity.
**Parameters**
* `entity` :`Engine.Entity` — base node entity
* `doubleSlipSwitch` :`boolean` — double slip switch true to create double slip switch, false for single slip switch
**Returns**
1. `Proposal`
### UtilProposal.createTrafficLightProposal[🔗](#$api.engine.util~UtilProposal.createTrafficLightProposal)
```
function UtilProposal.createTrafficLightProposal(entity : Engine.Entity, trafficLightConfig : Engine.Component.TrafficLightConfig, trafficLightPreference : TrafficLightPreference): Proposal
```
Creates a proposal that changes the traffic light configuration of a base node
**Parameters**
* `entity` :`Engine.Entity` — base node entity
* `trafficLightConfig` :`Engine.Component.TrafficLightConfig` — the configuration of traffic light, including phases and type
* `trafficLightPreference` :`TrafficLightPreference` — whether a traffic light should be generated or not (or automtically decided)
**Returns**
1. `Proposal`
### UtilProposal.getBridgeOrTunnelRelatedRevisions[🔗](#$api.engine.util~UtilProposal.getBridgeOrTunnelRelatedRevisions)
```
function UtilProposal.getBridgeOrTunnelRelatedRevisions(parallelStripEntity : Engine.Entity): {Engine.Entity : Engine.Revision}
```
Gets bridge or tunnel related revisions for a parallel strip entity.
**Parameters**
* `parallelStripEntity` :`Engine.Entity` — parallel strip entity
**Returns**
1. `{Engine.Entity : Engine.Revision}` — map of entity to revision
### UtilProposal.didBridgeOrTunnelRelatedRevisionsChange[🔗](#$api.engine.util~UtilProposal.didBridgeOrTunnelRelatedRevisionsChange)
```
function UtilProposal.didBridgeOrTunnelRelatedRevisionsChange(parallelStripEntity : Engine.Entity, revisions : {Engine.Entity : Engine.Revision}): boolean
```
Checks if bridge or tunnel related revisions changed for a parallel strip entity.
**Parameters**
* `parallelStripEntity` :`Engine.Entity` — parallel strip entity
* `revisions` :`{Engine.Entity : Engine.Revision}` — map of entity to revision
**Returns**
1. `boolean` — true if any related revision changed
### UtilProposal.makeReforestationProposal[🔗](#$api.engine.util~UtilProposal.makeReforestationProposal)
```
function UtilProposal.makeReforestationProposal(seed : integer, numTilesToUpdate : integer, maxTreesPerTile : integer): Proposal
```
Creates a reforestation proposal.
**Parameters**
* `seed` :`integer` — random seed
* `numTilesToUpdate` :`integer` — maximum number of tiles being updated
* `maxTreesPerTile` :`integer` — maximum number of trees planted per tile
**Returns**
1. `Proposal` — the generated proposal
### UtilProposal.refreshConstruction[🔗](#$api.engine.util~UtilProposal.refreshConstruction)
```
function UtilProposal.refreshConstruction(entity : Engine.Entity, constructionFilepath : string): Proposal
```
Refreshes a construction. This returns a proposal that needs to be applied with a `makeWorldBuildProposalCmd`
**Parameters**
* `entity` :`Engine.Entity` — the entity with a construction to refresh
* `constructionFilepath` :`string` — the construction to refresh the entity with
**Returns**
1. `Proposal` — a proposal for the refreshed construction
### UtilProposal.replaceSegment[🔗](#$api.engine.util~UtilProposal.replaceSegment)
```
function UtilProposal.replaceSegment(entity : Engine.Entity, streetTemplate : ResName): Proposal
```
Refreshes a street/track segment (base edge). This returns a proposal that needs to be applied with a `makeWorldBuildProposalCmd`
**Parameters**
* `entity` :`Engine.Entity` — the entity with a construction to refresh
* `streetTemplate` :`ResName` — the street template file path to refresh the entity with (optionally). Use with caution.
**Returns**
1. `Proposal` — a proposal for the refreshed segment
### UtilProposal.checkProposalConnectsNodes[🔗](#$api.engine.util~UtilProposal.checkProposalConnectsNodes)
```
function UtilProposal.checkProposalConnectsNodes(startNode : Engine.Entity, startEdge : Engine.Entity, targetNode : Engine.Entity, streetProposal : Proposal.StreetProposal, isApply : boolean, maxDepth : number): boolean
```
Check if a street proposal connects the start node to the target node.
**Parameters**
* `startNode` :`Engine.Entity` — the starting base node entity
* `startEdge` :`Engine.Entity` — the starting base edge entity
* `targetNode` :`Engine.Entity` — the target node entity
* `streetProposal` :`Proposal.StreetProposal` — the street proposal to check
* `isApply` :`boolean` — whether the proposal is being applied
* `maxDepth` :`number` — (optional) specify a maximum distance which is traversed in the network
**Returns**
1. `boolean` — true if the proposal connects the nodes
### UtilProposal.makeIndustryExtendProposal[🔗](#$api.engine.util~UtilProposal.makeIndustryExtendProposal)
```
function UtilProposal.makeIndustryExtendProposal(industry : Engine.Entity, trySlots : integer, numExtendSlots : integer): {Proposal, {integer}}
```
Create proposal to extend industry
**Parameters**
* `industry` :`Engine.Entity` — industry entity
* `trySlots` :`integer` — number of slots to try extending to
* `numExtendSlots` :`integer` — number of slots to extend
**Returns**
1. `{Proposal, {integer}}` — the proposal and (if it is colliding) indices of colliding subconstructions
### UtilProposal.createSubconstructionLotList[🔗](#$api.engine.util~UtilProposal.createSubconstructionLotList)
```
function UtilProposal.createSubconstructionLotList(Proposal.Subconstruction, Mat4f): Engine.Component.LotList
```
**Parameters**
* `Proposal.Subconstruction`
* `Mat4f`
**Returns**
1. `Engine.Component.LotList`
### UtilProposal.getConstructionArea[🔗](#$api.engine.util~UtilProposal.getConstructionArea)
```
function UtilProposal.getConstructionArea(proposal : Proposal): number
```
Calculate the area of new constructions in the proposal.
**Parameters**
* `proposal` :`Proposal` — the proposal to calculate the area for
**Returns**
1. `number` — the approximate area of new constructions in the proposal in square meters
### UtilStation[🔗](#$api.engine.util~UtilStation)
```
[Expand All] [Collapse All]
global record UtilStation record StationUsage totalUsed: integer
overflow: integer
poolCapacity: integer
terminalCapacity: integer
end
calculateStationUsage: function(station : Engine.Entity): StationUsage
calculateStationTerminalUsage: function(station : Engine.Entity, terminalIndex : integer): UtilLine.TerminalCapacityUsage
record StationGroupCapacityUsage equals: function(StationGroupCapacityUsage, StationGroupCapacityUsage): boolean
capacity: integer
waitingHallCapacity: integer
used: integer
overflow: boolean
end
calculateStationGroupCargo: function(stationGroup : Engine.Entity, flatTerminalIndex : integer): StationGroupCapacityUsage
isStationOfType: function(stationEntity : Engine.Entity, cargo : boolean): boolean
findStationGroupWithOverlappingCatchmentOfDifferentCarriers: function(): {{Engine.Entity, Engine.Entity}}
end
```
### UtilStation.StationUsage[🔗](#$api.engine.util~UtilStation.StationUsage)
```
record UtilStation.StationUsage totalUsed: integer
overflow: integer
poolCapacity: integer
terminalCapacity: integer
end
```
### UtilStation.StationUsage.totalUsed[🔗](#$api.engine.util~UtilStation.StationUsage.totalUsed)
```
UtilStation.StationUsage.totalUsed: integer
```
### UtilStation.StationUsage.overflow[🔗](#$api.engine.util~UtilStation.StationUsage.overflow)
```
UtilStation.StationUsage.overflow: integer
```
### UtilStation.StationUsage.poolCapacity[🔗](#$api.engine.util~UtilStation.StationUsage.poolCapacity)
```
UtilStation.StationUsage.poolCapacity: integer
```
### UtilStation.StationUsage.terminalCapacity[🔗](#$api.engine.util~UtilStation.StationUsage.terminalCapacity)
```
UtilStation.StationUsage.terminalCapacity: integer
```
### UtilStation.calculateStationUsage[🔗](#$api.engine.util~UtilStation.calculateStationUsage)
```
function UtilStation.calculateStationUsage(station : Engine.Entity): StationUsage
```
Get station usages
**Parameters**
* `station` :`Engine.Entity` — station entity
**Returns**
1. `StationUsage` — total usage, overflow and pool capacity for station
### UtilStation.calculateStationTerminalUsage[🔗](#$api.engine.util~UtilStation.calculateStationTerminalUsage)
```
function UtilStation.calculateStationTerminalUsage(station : Engine.Entity, terminalIndex : integer): UtilLine.TerminalCapacityUsage
```
Get station terminal usages
**Parameters**
* `station` :`Engine.Entity` — station entity
* `terminalIndex` :`integer` — terminal index
**Returns**
1. `UtilLine.TerminalCapacityUsage` — capacity and usage for a terminal (or the pool if terminal is -1)
### UtilStation.StationGroupCapacityUsage[🔗](#$api.engine.util~UtilStation.StationGroupCapacityUsage)
```
record UtilStation.StationGroupCapacityUsage equals: function(StationGroupCapacityUsage, StationGroupCapacityUsage): boolean
capacity: integer
waitingHallCapacity: integer
used: integer
overflow: boolean
end
```
### UtilStation.StationGroupCapacityUsage.equals[🔗](#$api.engine.util~UtilStation.StationGroupCapacityUsage.equals)
```
function UtilStation.StationGroupCapacityUsage.equals(StationGroupCapacityUsage, StationGroupCapacityUsage): boolean
```
**Parameters**
* `StationGroupCapacityUsage`
* `StationGroupCapacityUsage`
**Returns**
1. `boolean`
### UtilStation.StationGroupCapacityUsage.capacity[🔗](#$api.engine.util~UtilStation.StationGroupCapacityUsage.capacity)
```
UtilStation.StationGroupCapacityUsage.capacity: integer
```
### UtilStation.StationGroupCapacityUsage.waitingHallCapacity[🔗](#$api.engine.util~UtilStation.StationGroupCapacityUsage.waitingHallCapacity)
```
UtilStation.StationGroupCapacityUsage.waitingHallCapacity: integer
```
### UtilStation.StationGroupCapacityUsage.used[🔗](#$api.engine.util~UtilStation.StationGroupCapacityUsage.used)
```
UtilStation.StationGroupCapacityUsage.used: integer
```
### UtilStation.StationGroupCapacityUsage.overflow[🔗](#$api.engine.util~UtilStation.StationGroupCapacityUsage.overflow)
```
UtilStation.StationGroupCapacityUsage.overflow: boolean
```
### UtilStation.calculateStationGroupCargo[🔗](#$api.engine.util~UtilStation.calculateStationGroupCargo)
```
function UtilStation.calculateStationGroupCargo(stationGroup : Engine.Entity, flatTerminalIndex : integer): StationGroupCapacityUsage
```
Get station group cargo usage
**Parameters**
* `stationGroup` :`Engine.Entity` — station group entity
* `flatTerminalIndex` :`integer` — terminal index
**Returns**
1. `StationGroupCapacityUsage` — capacity and usage + overflow for a StationGroup
### UtilStation.isStationOfType[🔗](#$api.engine.util~UtilStation.isStationOfType)
```
function UtilStation.isStationOfType(stationEntity : Engine.Entity, cargo : boolean): boolean
```
Check if station supports cargo/passengers
**Parameters**
* `stationEntity` :`Engine.Entity` — station entity
* `cargo` :`boolean` — check for cargo support or passenger support
**Returns**
1. `boolean` — whether station supports cargo/passengers
### UtilStation.findStationGroupWithOverlappingCatchmentOfDifferentCarriers[🔗](#$api.engine.util~UtilStation.findStationGroupWithOverlappingCatchmentOfDifferentCarriers)
```
function UtilStation.findStationGroupWithOverlappingCatchmentOfDifferentCarriers(): {{Engine.Entity, Engine.Entity}}
```
Check for stations with overlapping catchment areas
**Returns**
1. `{{Engine.Entity, Engine.Entity}}` — list of station group entity pairs
### UtilStock[🔗](#$api.engine.util~UtilStock)
```
global record UtilStock getStockCargoTypes: function(stockListEntity : Engine.Entity, stockId : StockId): {CargoTypeId}
getCargoTypeShippedPerYear: function(stockListEntity : Engine.Entity, cargoTypeId : CargoTypeId): integer
getCargoShippedPerYear: function(stockListEntity : Engine.Entity): integer
getCargoTypeDeliveredPerYear: function(stockListEntity : Engine.Entity, cargoTypeId : CargoTypeId): integer
getCargoDeliveredPerYear: function(stockListEntity : Engine.Entity): integer
getCargoConsumedPerYear: function(stockListEntity : Engine.Entity, cargoTypeId : CargoTypeId): integer
getCargoProducedPerYear: function(stockListEntity : Engine.Entity, cargoTypeId : CargoTypeId): integer
getCargoMaxProductionPerYear: function(stockListEntity : Engine.Entity, cargoTypeId : CargoTypeId): integer
getCargoMaxConsumptionPerYear: function(stockListEntity : Engine.Entity, cargoTypeId : CargoTypeId): integer
getInputsOutputsFromRules: function(stockListEntity : Engine.Entity): {{CargoTypeId}, {CargoTypeId}}
getCargoOutputPerYear: function(stockListEntity : Engine.Entity): integer
getCargoLogValueDiffPerYear: function(stockListEntity : Engine.Entity, logType : string, cargoTypeId : CargoTypeId): integer
getCargoLogPerYearForTarget: function(sourceStockListEntity : Engine.Entity, targetStockListEntity : Engine.Entity, logType : string, cargoTypeId : CargoTypeId): integer
getCargoLogPerYearForTargetFilter: function(sourceStockListEntity : Engine.Entity, targetFilter : function(Engine.Entity) : boolean, logType : string, cargoTypeId : CargoTypeId): integer
getProductionRating: function(stockListEntity : Engine.Entity): number
getStockGroupsByTypeAndCargoTypes: function(stockListEntity : Engine.Entity, sortByType : boolean, showEmpty : boolean): {{StockListType, {StockId}, {CargoTypeId}, integer}}
getStockListsWithThrownAwayCargo: function(): {Engine.Entity : integer}
hasAnyCompatibleStock: function(entities : {Engine.Entity}, cargoTypeId : CargoTypeId, load : boolean): boolean
getAdjustedDeliveryTime: function(cargoTypeId : CargoTypeId): integer
isCargoTypeCurrentlyProduced: function(cargoTypeId : CargoTypeId): boolean
end
```
### UtilStock.getStockCargoTypes[🔗](#$api.engine.util~UtilStock.getStockCargoTypes)
```
function UtilStock.getStockCargoTypes(stockListEntity : Engine.Entity, stockId : StockId): {CargoTypeId}
```
Get stock cargo types.
**Parameters**
* `stockListEntity` :`Engine.Entity` — entity containting the stocklist component
* `stockId` :`StockId` — stock id
**Returns**
1. `{CargoTypeId}` — set of CargoTypeId
### UtilStock.getCargoTypeShippedPerYear[🔗](#$api.engine.util~UtilStock.getCargoTypeShippedPerYear)
```
function UtilStock.getCargoTypeShippedPerYear(stockListEntity : Engine.Entity, cargoTypeId : CargoTypeId): integer
```
Get num cargo shipped per year
**Parameters**
* `stockListEntity` :`Engine.Entity` — list entity
* `cargoTypeId` :`CargoTypeId` — cargo type id
**Returns**
1. `integer` — num cargo shipped per year
### UtilStock.getCargoShippedPerYear[🔗](#$api.engine.util~UtilStock.getCargoShippedPerYear)
```
function UtilStock.getCargoShippedPerYear(stockListEntity : Engine.Entity): integer
```
Get num cargo shipped per year
**Parameters**
* `stockListEntity` :`Engine.Entity` — list entity
**Returns**
1. `integer` — num cargo shipped per year
### UtilStock.getCargoTypeDeliveredPerYear[🔗](#$api.engine.util~UtilStock.getCargoTypeDeliveredPerYear)
```
function UtilStock.getCargoTypeDeliveredPerYear(stockListEntity : Engine.Entity, cargoTypeId : CargoTypeId): integer
```
Get num cargo delivered per year
**Parameters**
* `stockListEntity` :`Engine.Entity` — list entity
* `cargoTypeId` :`CargoTypeId` — cargo type id
**Returns**
1. `integer` — num cargo delivered per year
### UtilStock.getCargoDeliveredPerYear[🔗](#$api.engine.util~UtilStock.getCargoDeliveredPerYear)
```
function UtilStock.getCargoDeliveredPerYear(stockListEntity : Engine.Entity): integer
```
Get num cargo delivered (to entity) per year
**Parameters**
* `stockListEntity` :`Engine.Entity` — stock list entity
**Returns**
1. `integer` — num cargo delivered per year
### UtilStock.getCargoConsumedPerYear[🔗](#$api.engine.util~UtilStock.getCargoConsumedPerYear)
```
function UtilStock.getCargoConsumedPerYear(stockListEntity : Engine.Entity, cargoTypeId : CargoTypeId): integer
```
Get num cargo consumed per year
**Parameters**
* `stockListEntity` :`Engine.Entity` — list entity
* `cargoTypeId` :`CargoTypeId` — cargo type id
**Returns**
1. `integer` — num cargo consumed per year
### UtilStock.getCargoProducedPerYear[🔗](#$api.engine.util~UtilStock.getCargoProducedPerYear)
```
function UtilStock.getCargoProducedPerYear(stockListEntity : Engine.Entity, cargoTypeId : CargoTypeId): integer
```
Get num cargo produced per year
**Parameters**
* `stockListEntity` :`Engine.Entity` — list entity
* `cargoTypeId` :`CargoTypeId` — cargo type id
**Returns**
1. `integer` — num cargo produced per year
### UtilStock.getCargoMaxProductionPerYear[🔗](#$api.engine.util~UtilStock.getCargoMaxProductionPerYear)
```
function UtilStock.getCargoMaxProductionPerYear(stockListEntity : Engine.Entity, cargoTypeId : CargoTypeId): integer
```
Get num cargo max production per year
**Parameters**
* `stockListEntity` :`Engine.Entity` — list entity
* `cargoTypeId` :`CargoTypeId` — cargo type id
**Returns**
1. `integer` — num cargo max production per year
### UtilStock.getCargoMaxConsumptionPerYear[🔗](#$api.engine.util~UtilStock.getCargoMaxConsumptionPerYear)
```
function UtilStock.getCargoMaxConsumptionPerYear(stockListEntity : Engine.Entity, cargoTypeId : CargoTypeId): integer
```
Get num cargo max consumption per year
**Parameters**
* `stockListEntity` :`Engine.Entity` — list entity
* `cargoTypeId` :`CargoTypeId` — cargo type id
**Returns**
1. `integer` — num cargo max consumption per year
### UtilStock.getInputsOutputsFromRules[🔗](#$api.engine.util~UtilStock.getInputsOutputsFromRules)
```
function UtilStock.getInputsOutputsFromRules(stockListEntity : Engine.Entity): {{CargoTypeId}, {CargoTypeId}}
```
Get inputs and outputs from rules
**Parameters**
* `stockListEntity` :`Engine.Entity` — list entity
**Returns**
1. `{{CargoTypeId}, {CargoTypeId}}` — inputs and outputs cargo types
### UtilStock.getCargoOutputPerYear[🔗](#$api.engine.util~UtilStock.getCargoOutputPerYear)
```
function UtilStock.getCargoOutputPerYear(stockListEntity : Engine.Entity): integer
```
Get the total number of cargo produced per year
**Parameters**
* `stockListEntity` :`Engine.Entity` — list entity
**Returns**
1. `integer` — num cargo produced per year
### UtilStock.getCargoLogValueDiffPerYear[🔗](#$api.engine.util~UtilStock.getCargoLogValueDiffPerYear)
```
function UtilStock.getCargoLogValueDiffPerYear(stockListEntity : Engine.Entity, logType : string, cargoTypeId : CargoTypeId): integer
```
Get cargo log value in the last year for cargo type
**Parameters**
* `stockListEntity` :`Engine.Entity` — stock list entity
* `logType` :`string` — the logbook type
* `cargoTypeId` :`CargoTypeId` — cargo type
**Returns**
1. `integer` — cargo log value difference in the last year for cargo type
### UtilStock.getCargoLogPerYearForTarget[🔗](#$api.engine.util~UtilStock.getCargoLogPerYearForTarget)
```
function UtilStock.getCargoLogPerYearForTarget(sourceStockListEntity : Engine.Entity, targetStockListEntity : Engine.Entity, logType : string, cargoTypeId : CargoTypeId): integer
```
Get num cargo log per year
**Parameters**
* `sourceStockListEntity` :`Engine.Entity` — stock list entity
* `targetStockListEntity` :`Engine.Entity` — stock list entity
* `logType` :`string` — the logbook type
* `cargoTypeId` :`CargoTypeId` — the cargo type
**Returns**
1. `integer` — num cargo shipped per year
### UtilStock.getCargoLogPerYearForTargetFilter[🔗](#$api.engine.util~UtilStock.getCargoLogPerYearForTargetFilter)
```
function UtilStock.getCargoLogPerYearForTargetFilter(sourceStockListEntity : Engine.Entity, targetFilter : function(Engine.Entity) : boolean, logType : string, cargoTypeId : CargoTypeId): integer
```
Get num cargo log per year
**Parameters**
* `sourceStockListEntity` :`Engine.Entity` — stock list entity
* `targetFilter` :`function(Engine.Entity): boolean` — filter function to filter target entities
* `logType` :`string` — the logbook type
* `cargoTypeId` :`CargoTypeId` — the cargo type
**Returns**
1. `integer` — num cargo shipped per year
### UtilStock.getProductionRating[🔗](#$api.engine.util~UtilStock.getProductionRating)
```
function UtilStock.getProductionRating(stockListEntity : Engine.Entity): number
```
Get stocklist production rating
**Parameters**
* `stockListEntity` :`Engine.Entity` — list entity
**Returns**
1. `number` — production rating
### UtilStock.getStockGroupsByTypeAndCargoTypes[🔗](#$api.engine.util~UtilStock.getStockGroupsByTypeAndCargoTypes)
```
function UtilStock.getStockGroupsByTypeAndCargoTypes(stockListEntity : Engine.Entity, sortByType : boolean, showEmpty : boolean): {{StockListType, {StockId}, {CargoTypeId}, integer}}
```
Get stock groups by type and cargo types
**Parameters**
* `stockListEntity` :`Engine.Entity` — list entity
* `sortByType` :`boolean` — sort by type
* `showEmpty` :`boolean` — show empty groups
**Returns**
1. `{{StockListType, {StockId}, {CargoTypeId}, integer}}` — {StockListType, {StockId}, {CargoTypeId}, int} list of stock list type, stock ids, cargo types and count per group
### UtilStock.getStockListsWithThrownAwayCargo[🔗](#$api.engine.util~UtilStock.getStockListsWithThrownAwayCargo)
```
function UtilStock.getStockListsWithThrownAwayCargo(): {Engine.Entity : integer}
```
Get stock lists with thrown away cargo
**Returns**
1. `{Engine.Entity : integer}` — map of entity to amount thrown away
### UtilStock.hasAnyCompatibleStock[🔗](#$api.engine.util~UtilStock.hasAnyCompatibleStock)
```
function UtilStock.hasAnyCompatibleStock(entities : {Engine.Entity}, cargoTypeId : CargoTypeId, load : boolean): boolean
```
Check if any stock is compatible
**Parameters**
* `entities` :`{Engine.Entity}` — list of entities to check
* `cargoTypeId` :`CargoTypeId` — cargo type
* `load` :`boolean` — whether to check for loading/input (true) or unloading/output (false)
**Returns**
1. `boolean` — true if any stock is compatible
### UtilStock.getAdjustedDeliveryTime[🔗](#$api.engine.util~UtilStock.getAdjustedDeliveryTime)
```
function UtilStock.getAdjustedDeliveryTime(cargoTypeId : CargoTypeId): integer
```
Get adjusted delivery time
**Parameters**
* `cargoTypeId` :`CargoTypeId` — cargo type
**Returns**
1. `integer` — adjusted delivery time in seconds
### UtilStock.isCargoTypeCurrentlyProduced[🔗](#$api.engine.util~UtilStock.isCargoTypeCurrentlyProduced)
```
function UtilStock.isCargoTypeCurrentlyProduced(cargoTypeId : CargoTypeId): boolean
```
Check if cargo type is currently produced
**Parameters**
* `cargoTypeId` :`CargoTypeId` — cargo type
**Returns**
1. `boolean` — true if cargo type is currently produced
### UtilTown[🔗](#$api.engine.util~UtilTown)
```
[Expand All] [Collapse All]
global record UtilTown record TownReachability commercialPrivate: integer
commercialPublic: integer
industrialPrivate: integer
industrialPublic: integer
end
record TownCapacityUsage used: integer
capacity: integer
end
record TownEmission noise: number
pollution: number
areaSquareKm: number
end
record DestinationUseCount count: integer
linesUseCount: integer
end
record TownHappinessStats record ByResident resident: {integer, integer}
nonResident: {integer, integer}
end
travellingInside: {integer, integer}
travellingTo: ByResident
travellingFrom: ByResident
atBuilding: {integer, integer}
byCar: {integer, integer}
walking: {integer, integer}
byLine: {{Engine.Entity, ByResident}}
end
computeWeightedTargetTownBuildingCapacityPerType: function(townEntity : Engine.Entity): {{integer, integer, integer, integer}}
computeUnweightedTargetTownBuildingCapacityPerType: function(townEntity : Engine.Entity): {{integer, integer, integer, integer}}
computeActualTownBuildingCapacityPerType: function(townEntity : Engine.Entity): {{integer, integer, integer, integer}}
getLandUse2CargoTypes: function(): {LandUseType : {CargoTypeId}}
getTownReachability: function(townEntity : Engine.Entity): TownReachability
getTownEmission: function(townEntity : Engine.Entity): TownEmission
getTownEmissionDB: function(townEntity : Engine.Entity): TownEmission
getTownCapacityUsage: function(townEntity : Engine.Entity): {TownCapacityUsage}
getTownHappinessStats: function(townEntity : Engine.Entity, numTopLines : integer): TownHappinessStats
getTownDeliveriesStats: function(townEntity : Engine.Entity, interval : integer, perLine : boolean, perCargoType : boolean): {Engine.Entity : {CargoTypeId : {integer, integer}}}
getTownStockCargo: function(townEntity : Engine.Entity): {CargoTypeId : {integer, integer}}
getTerrainBrushVolumeImpact: function(proposal : Proposal): {Engine.Entity : {number, number}}
getTerrainAlignmentImpact: function(proposalData : ProposalData): {Engine.Entity : {number, number}}
getAutoRemovalEntityImpact: function(proposalData : ProposalData): {Engine.Entity : {number, number}}
getTownNoisePerDistrict: function(townEntity : Engine.Entity, landUseTypes : {LandUseType}): {LandUseType : {number, integer}}
getImpactFromDistance: function(distance : number): number
computeTownsTrafficSpeedMap: function(samplesCoefficient : number): {Engine.Entity : {number, {integer}}}
getTownProblems: function(): {{{Engine.Entity}, TownProblem}}
isNeighbourTown: function(townEntity1 : Engine.Entity, townEntity2 : Engine.Entity): boolean
getClosestTown: function(position : Vec3f): Engine.Entity
getRandomTownPosition: function(townEntity : Engine.Entity, seed : integer): Vec2f
isLineStoppingInTown: function(lineEntity : Engine.Entity, townEntity : Engine.Entity): boolean
getTownLineUsage: function(townEntity : Engine.Entity): number
getSourceToDestinationCount: function(townEntitiy : Engine.Entity, destinationIsTownMap : {Engine.Entity : boolean}, selectLandUse : integer): {Engine.Entity : DestinationUseCount}
getTownDistrictCenter: function(entity : Engine.Entity, landUseTypes : LandUseType): Vec3f
end
```
### UtilTown.TownReachability[🔗](#$api.engine.util~UtilTown.TownReachability)
```
record UtilTown.TownReachability commercialPrivate: integer
commercialPublic: integer
industrialPrivate: integer
industrialPublic: integer
end
```
### UtilTown.TownReachability.commercialPrivate[🔗](#$api.engine.util~UtilTown.TownReachability.commercialPrivate)
```
UtilTown.TownReachability.commercialPrivate: integer
```
### UtilTown.TownReachability.commercialPublic[🔗](#$api.engine.util~UtilTown.TownReachability.commercialPublic)
```
UtilTown.TownReachability.commercialPublic: integer
```
### UtilTown.TownReachability.industrialPrivate[🔗](#$api.engine.util~UtilTown.TownReachability.industrialPrivate)
```
UtilTown.TownReachability.industrialPrivate: integer
```
### UtilTown.TownReachability.industrialPublic[🔗](#$api.engine.util~UtilTown.TownReachability.industrialPublic)
```
UtilTown.TownReachability.industrialPublic: integer
```
### UtilTown.TownCapacityUsage[🔗](#$api.engine.util~UtilTown.TownCapacityUsage)
```
record UtilTown.TownCapacityUsage used: integer
capacity: integer
end
```
### UtilTown.TownCapacityUsage.used[🔗](#$api.engine.util~UtilTown.TownCapacityUsage.used)
```
UtilTown.TownCapacityUsage.used: integer
```
### UtilTown.TownCapacityUsage.capacity[🔗](#$api.engine.util~UtilTown.TownCapacityUsage.capacity)
```
UtilTown.TownCapacityUsage.capacity: integer
```
### UtilTown.TownEmission[🔗](#$api.engine.util~UtilTown.TownEmission)
```
record UtilTown.TownEmission noise: number
pollution: number
areaSquareKm: number
end
```
### UtilTown.TownEmission.noise[🔗](#$api.engine.util~UtilTown.TownEmission.noise)
```
UtilTown.TownEmission.noise: number
```
### UtilTown.TownEmission.pollution[🔗](#$api.engine.util~UtilTown.TownEmission.pollution)
```
UtilTown.TownEmission.pollution: number
```
### UtilTown.TownEmission.areaSquareKm[🔗](#$api.engine.util~UtilTown.TownEmission.areaSquareKm)
```
UtilTown.TownEmission.areaSquareKm: number
```
### UtilTown.DestinationUseCount[🔗](#$api.engine.util~UtilTown.DestinationUseCount)
```
record UtilTown.DestinationUseCount count: integer
linesUseCount: integer
end
```
### UtilTown.DestinationUseCount.count[🔗](#$api.engine.util~UtilTown.DestinationUseCount.count)
```
UtilTown.DestinationUseCount.count: integer
```
### UtilTown.DestinationUseCount.linesUseCount[🔗](#$api.engine.util~UtilTown.DestinationUseCount.linesUseCount)
```
UtilTown.DestinationUseCount.linesUseCount: integer
```
### UtilTown.TownHappinessStats[🔗](#$api.engine.util~UtilTown.TownHappinessStats)
```
[Expand All] [Collapse All]
record UtilTown.TownHappinessStats record ByResident resident: {integer, integer}
nonResident: {integer, integer}
end
travellingInside: {integer, integer}
travellingTo: ByResident
travellingFrom: ByResident
atBuilding: {integer, integer}
byCar: {integer, integer}
walking: {integer, integer}
byLine: {{Engine.Entity, ByResident}}
end
```
### UtilTown.TownHappinessStats.ByResident[🔗](#$api.engine.util~UtilTown.TownHappinessStats.ByResident)
```
record UtilTown.TownHappinessStats.ByResident resident: {integer, integer}
nonResident: {integer, integer}
end
```
### UtilTown.TownHappinessStats.ByResident.resident[🔗](#$api.engine.util~UtilTown.TownHappinessStats.ByResident.resident)
```
UtilTown.TownHappinessStats.ByResident.resident: {integer, integer}
```
### UtilTown.TownHappinessStats.ByResident.nonResident[🔗](#$api.engine.util~UtilTown.TownHappinessStats.ByResident.nonResident)
```
UtilTown.TownHappinessStats.ByResident.nonResident: {integer, integer}
```
### UtilTown.TownHappinessStats.travellingInside[🔗](#$api.engine.util~UtilTown.TownHappinessStats.travellingInside)
```
UtilTown.TownHappinessStats.travellingInside: {integer, integer}
```
### UtilTown.TownHappinessStats.travellingTo[🔗](#$api.engine.util~UtilTown.TownHappinessStats.travellingTo)
```
UtilTown.TownHappinessStats.travellingTo: ByResident
```
### UtilTown.TownHappinessStats.travellingFrom[🔗](#$api.engine.util~UtilTown.TownHappinessStats.travellingFrom)
```
UtilTown.TownHappinessStats.travellingFrom: ByResident
```
### UtilTown.TownHappinessStats.atBuilding[🔗](#$api.engine.util~UtilTown.TownHappinessStats.atBuilding)
```
UtilTown.TownHappinessStats.atBuilding: {integer, integer}
```
### UtilTown.TownHappinessStats.byCar[🔗](#$api.engine.util~UtilTown.TownHappinessStats.byCar)
```
UtilTown.TownHappinessStats.byCar: {integer, integer}
```
### UtilTown.TownHappinessStats.walking[🔗](#$api.engine.util~UtilTown.TownHappinessStats.walking)
```
UtilTown.TownHappinessStats.walking: {integer, integer}
```
### UtilTown.TownHappinessStats.byLine[🔗](#$api.engine.util~UtilTown.TownHappinessStats.byLine)
```
UtilTown.TownHappinessStats.byLine: {{Engine.Entity, ByResident}}
```
### UtilTown.computeWeightedTargetTownBuildingCapacityPerType[🔗](#$api.engine.util~UtilTown.computeWeightedTargetTownBuildingCapacityPerType)
```
function UtilTown.computeWeightedTargetTownBuildingCapacityPerType(townEntity : Engine.Entity): {{integer, integer, integer, integer}}
```
Get weighted target level to capacities distribution for each land use type for the town
**Parameters**
* `townEntity` :`Engine.Entity` — town entity
**Returns**
1. `{{integer, integer, integer, integer}}` — level to capacities distribution
### UtilTown.computeUnweightedTargetTownBuildingCapacityPerType[🔗](#$api.engine.util~UtilTown.computeUnweightedTargetTownBuildingCapacityPerType)
```
function UtilTown.computeUnweightedTargetTownBuildingCapacityPerType(townEntity : Engine.Entity): {{integer, integer, integer, integer}}
```
Get unweighted target level to capacities distribution for each land use type for the town
**Parameters**
* `townEntity` :`Engine.Entity` — town entity
**Returns**
1. `{{integer, integer, integer, integer}}` — level to capacities distribution
### UtilTown.computeActualTownBuildingCapacityPerType[🔗](#$api.engine.util~UtilTown.computeActualTownBuildingCapacityPerType)
```
function UtilTown.computeActualTownBuildingCapacityPerType(townEntity : Engine.Entity): {{integer, integer, integer, integer}}
```
Get actual level to capacities distribution for each land use type for the town
**Parameters**
* `townEntity` :`Engine.Entity` — town entity
**Returns**
1. `{{integer, integer, integer, integer}}` — level to capacities distribution
### UtilTown.getLandUse2CargoTypes[🔗](#$api.engine.util~UtilTown.getLandUse2CargoTypes)
```
function UtilTown.getLandUse2CargoTypes(): {LandUseType : {CargoTypeId}}
```
Get town available cargo needs
**Returns**
1. `{LandUseType : {CargoTypeId}}` — map of land use to cargo types
### UtilTown.getTownReachability[🔗](#$api.engine.util~UtilTown.getTownReachability)
```
function UtilTown.getTownReachability(townEntity : Engine.Entity): TownReachability
```
Get town reachability
**Parameters**
* `townEntity` :`Engine.Entity` — town entity
**Returns**
1. `TownReachability` — reachability data
### UtilTown.getTownEmission[🔗](#$api.engine.util~UtilTown.getTownEmission)
```
function UtilTown.getTownEmission(townEntity : Engine.Entity): TownEmission
```
Get town emission in power
**Parameters**
* `townEntity` :`Engine.Entity` — town entity
**Returns**
1. `TownEmission` — emission data in power
### UtilTown.getTownEmissionDB[🔗](#$api.engine.util~UtilTown.getTownEmissionDB)
```
function UtilTown.getTownEmissionDB(townEntity : Engine.Entity): TownEmission
```
Get town emission in decibel
**Parameters**
* `townEntity` :`Engine.Entity` — town entity
**Returns**
1. `TownEmission` — emission data in decibel
### UtilTown.getTownCapacityUsage[🔗](#$api.engine.util~UtilTown.getTownCapacityUsage)
```
function UtilTown.getTownCapacityUsage(townEntity : Engine.Entity): {TownCapacityUsage}
```
Get town capacity usage
**Parameters**
* `townEntity` :`Engine.Entity` — town entity
**Returns**
1. `{TownCapacityUsage}` — capacity usage per land use type
### UtilTown.getTownHappinessStats[🔗](#$api.engine.util~UtilTown.getTownHappinessStats)
```
function UtilTown.getTownHappinessStats(townEntity : Engine.Entity, numTopLines : integer): TownHappinessStats
```
Get number of unhappy people travelling by lines to or from the town
**Parameters**
* `townEntity` :`Engine.Entity` — town entity
* `numTopLines` :`integer` — number of top lines to consider for the stat
**Returns**
1. `TownHappinessStats` — number of unhappy and total people travelling by lines
### UtilTown.getTownDeliveriesStats[🔗](#$api.engine.util~UtilTown.getTownDeliveriesStats)
```
function UtilTown.getTownDeliveriesStats(townEntity : Engine.Entity, interval : integer, perLine : boolean, perCargoType : boolean): {Engine.Entity : {CargoTypeId : {integer, integer}}}
```
Get town cargo deliveries stats
**Parameters**
* `townEntity` :`Engine.Entity` — town entity
* `interval` :`integer` — time interval in miliseconds for the stats
* `perLine` :`boolean` — whether to get stats per line
* `perCargoType` :`boolean` — whether to get stats per cargo type
**Returns**
1. `{Engine.Entity : {CargoTypeId : {integer, integer}}}` — delivery stats
### UtilTown.getTownStockCargo[🔗](#$api.engine.util~UtilTown.getTownStockCargo)
```
function UtilTown.getTownStockCargo(townEntity : Engine.Entity): {CargoTypeId : {integer, integer}}
```
Obtains information about towns and cargo
**Parameters**
* `townEntity` :`Engine.Entity` — the entity of the town
**Returns**
1. `{CargoTypeId : {integer, integer}}` — map of cargo type to stock and capacity
### UtilTown.getTerrainBrushVolumeImpact[🔗](#$api.engine.util~UtilTown.getTerrainBrushVolumeImpact)
```
function UtilTown.getTerrainBrushVolumeImpact(proposal : Proposal): {Engine.Entity : {number, number}}
```
Get the impact of using terrain brush on towns reputation
**Parameters**
* `proposal` :`Proposal` — the terrain change proposal
**Returns**
1. `{Engine.Entity : {number, number}}` — the impact change for volume added and volume removed for each town
### UtilTown.getTerrainAlignmentImpact[🔗](#$api.engine.util~UtilTown.getTerrainAlignmentImpact)
```
function UtilTown.getTerrainAlignmentImpact(proposalData : ProposalData): {Engine.Entity : {number, number}}
```
Get the terrain alignment impact on towns reputation
**Parameters**
* `proposalData` :`ProposalData` — the proposal data
**Returns**
1. `{Engine.Entity : {number, number}}` — the impact change for volume added and volume removed for each town
### UtilTown.getAutoRemovalEntityImpact[🔗](#$api.engine.util~UtilTown.getAutoRemovalEntityImpact)
```
function UtilTown.getAutoRemovalEntityImpact(proposalData : ProposalData): {Engine.Entity : {number, number}}
```
Get the impact from auto removal of trees and rocks on towns reputation
**Parameters**
* `proposalData` :`ProposalData` — the proposal data
**Returns**
1. `{Engine.Entity : {number, number}}` — the impact change for removed trees and rocks for each town
### UtilTown.getTownNoisePerDistrict[🔗](#$api.engine.util~UtilTown.getTownNoisePerDistrict)
```
function UtilTown.getTownNoisePerDistrict(townEntity : Engine.Entity, landUseTypes : {LandUseType}): {LandUseType : {number, integer}}
```
Get town noise per district
**Parameters**
* `townEntity` :`Engine.Entity` — town entity
* `landUseTypes` :`{LandUseType}` — land use types to check
**Returns**
1. `{LandUseType : {number, integer}}` — average noise and affected capacity per district
### UtilTown.getImpactFromDistance[🔗](#$api.engine.util~UtilTown.getImpactFromDistance)
```
function UtilTown.getImpactFromDistance(distance : number): number
```
Get the impact for reputation the distance has for towns
**Parameters**
* `distance` :`number` — distance value
**Returns**
1. `number` — the impact from the distance
### UtilTown.computeTownsTrafficSpeedMap[🔗](#$api.engine.util~UtilTown.computeTownsTrafficSpeedMap)
```
function UtilTown.computeTownsTrafficSpeedMap(samplesCoefficient : number): {Engine.Entity : {number, {integer}}}
```
Get traffic speed for all towns
**Parameters**
* `samplesCoefficient` :`number` — coefficient to adjust the number of samples of streets used for traffic rating calculation
**Returns**
1. `{Engine.Entity : {number, {integer}}}` — traffic speed and number of streets per congestion level
### UtilTown.getTownProblems[🔗](#$api.engine.util~UtilTown.getTownProblems)
```
function UtilTown.getTownProblems(): {{{Engine.Entity}, TownProblem}}
```
Get towns with problems
**Returns**
1. `{{{Engine.Entity}, TownProblem}}` — town entity and problem
### UtilTown.isNeighbourTown[🔗](#$api.engine.util~UtilTown.isNeighbourTown)
```
function UtilTown.isNeighbourTown(townEntity1 : Engine.Entity, townEntity2 : Engine.Entity): boolean
```
Check if town is neighbor town
**Parameters**
* `townEntity1` :`Engine.Entity` — town entity
* `townEntity2` :`Engine.Entity` — town entity
**Returns**
1. `boolean` — whether town is neighbor
### UtilTown.getClosestTown[🔗](#$api.engine.util~UtilTown.getClosestTown)
```
function UtilTown.getClosestTown(position : Vec3f): Engine.Entity
```
Get closest town to position
**Parameters**
* `position` :`Vec3f` — world position
**Returns**
1. `Engine.Entity` — closest town entity
### UtilTown.getRandomTownPosition[🔗](#$api.engine.util~UtilTown.getRandomTownPosition)
```
function UtilTown.getRandomTownPosition(townEntity : Engine.Entity, seed : integer): Vec2f
```
Get a random 2d point inside the voronoi cell of the town
**Parameters**
* `townEntity` :`Engine.Entity` — the town in which to search
* `seed` :`integer` — a random seed for the generation
**Returns**
1. `Vec2f` — a point inside the town voronoi cell
### UtilTown.isLineStoppingInTown[🔗](#$api.engine.util~UtilTown.isLineStoppingInTown)
```
function UtilTown.isLineStoppingInTown(lineEntity : Engine.Entity, townEntity : Engine.Entity): boolean
```
Check if Line has at least 1 stop in the town's area
**Parameters**
* `lineEntity` :`Engine.Entity` — line entity
* `townEntity` :`Engine.Entity` — town entity
**Returns**
1. `boolean` — whether line stops in town
### UtilTown.getTownLineUsage[🔗](#$api.engine.util~UtilTown.getTownLineUsage)
```
function UtilTown.getTownLineUsage(townEntity : Engine.Entity): number
```
Get town line usage
**Parameters**
* `townEntity` :`Engine.Entity` — town entity
**Returns**
1. `number` — fraction of people using lines in the town
### UtilTown.getSourceToDestinationCount[🔗](#$api.engine.util~UtilTown.getSourceToDestinationCount)
```
function UtilTown.getSourceToDestinationCount(townEntitiy : Engine.Entity, destinationIsTownMap : {Engine.Entity : boolean}, selectLandUse : integer): {Engine.Entity : DestinationUseCount}
```
Get town destinations table content (work, shop and line usage info)
**Parameters**
* `townEntitiy` :`Engine.Entity` — town entity
* `destinationIsTownMap` :`{Engine.Entity : boolean}` — map of entity to isTown (destinations of town)
* `selectLandUse` :`integer` — 0 (Usage), 1 (Shopping), 2 (Work)
**Returns**
1. `{Engine.Entity : DestinationUseCount}` — destination use counts
### UtilTown.getTownDistrictCenter[🔗](#$api.engine.util~UtilTown.getTownDistrictCenter)
```
function UtilTown.getTownDistrictCenter(entity : Engine.Entity, landUseTypes : LandUseType): Vec3f
```
Get the district center of the town entity
**Parameters**
* `entity` :`Engine.Entity` — town entity
* `landUseTypes` :`LandUseType` — land use types to check
**Returns**
1. `Vec3f` — destination use counts
### UtilTransport[🔗](#$api.engine.util~UtilTransport)
```
global record UtilTransport calcPosition: function(eg : EdgeGeometry, t : number): Vec3f
calcPositionAndDirection: function(eg : EdgeGeometry, t : number, forward : boolean): {Vec3f}
transportModesToCarriers: function(transportModes : {TransportMode}): {Carrier}
getStartPort: function(edge : {EdgeId, boolean}): PortId
getEndPort: function(edge : {EdgeId, boolean}): PortId
isPortLocked: function(port : integer): boolean
end
```
### UtilTransport.calcPosition[🔗](#$api.engine.util~UtilTransport.calcPosition)
```
function UtilTransport.calcPosition(eg : EdgeGeometry, t : number): Vec3f
```
Calc position along a transport edge.
**Parameters**
* `eg` :`EdgeGeometry` — edge geometry
* `t` :`number` — progress along the edge [ 0, 1]
**Returns**
1. `Vec3f` — position on the edge
### UtilTransport.calcPositionAndDirection[🔗](#$api.engine.util~UtilTransport.calcPositionAndDirection)
```
function UtilTransport.calcPositionAndDirection(eg : EdgeGeometry, t : number, forward : boolean): {Vec3f}
```
Calc position along a transport edge.
**Parameters**
* `eg` :`EdgeGeometry` — edge geometry
* `t` :`number` — progress along the edge [ 0, 1]
* `forward` :`boolean` — optional bool (forward or backward t -> t - 1.0)
**Returns**
1. `{Vec3f}` — position on the edge and direction
### UtilTransport.transportModesToCarriers[🔗](#$api.engine.util~UtilTransport.transportModesToCarriers)
```
function UtilTransport.transportModesToCarriers(transportModes : {TransportMode}): {Carrier}
```
Transform list of transport modes to a vector of carriers.
**Parameters**
* `transportModes` :`{TransportMode}` — list of transport modes
**Returns**
1. `{Carrier}` — carriers for a given set of transport modes
### UtilTransport.getStartPort[🔗](#$api.engine.util~UtilTransport.getStartPort)
```
function UtilTransport.getStartPort(edge : {EdgeId, boolean}): PortId
```
Obtains the start connection of this edge.
**Parameters**
* `edge` :`{EdgeId, boolean}` — the edge with direction
**Returns**
1. `PortId` — PortId at the edge's start
### UtilTransport.getEndPort[🔗](#$api.engine.util~UtilTransport.getEndPort)
```
function UtilTransport.getEndPort(edge : {EdgeId, boolean}): PortId
```
Obtains the end connection of this edge.
**Parameters**
* `edge` :`{EdgeId, boolean}` — the edge with direction
**Returns**
1. `PortId` — PortId at the edge's end
### UtilTransport.isPortLocked[🔗](#$api.engine.util~UtilTransport.isPortLocked)
```
function UtilTransport.isPortLocked(port : integer): boolean
```
Check if a port is locked.
**Parameters**
* `port` :`integer` — the port
**Returns**
1. `boolean` — true if the port is locked, false otherwise
### UtilVehicle[🔗](#$api.engine.util~UtilVehicle)
```
global record UtilVehicle findBestLineAndDepotForVehicle: function(vehicleEntity : Engine.Entity): {Engine.Entity, Engine.Entity}
findBestDepotForLine: function(carrier : Carrier, transportModes : {TransportMode}, lineEntity : Engine.Entity, position : Vec3f): Engine.Entity
getSpeed: function(vehicleEntity : Engine.Entity): number
getPosition: function(vehicleEntity : Engine.Entity): Vec3f
calcPathPosData: function(vehicleEntity : Engine.Entity): PathPosData
getDirection: function(vehicleEntity : Engine.Entity): Vec3f
getVehiclesByCarrier: function(carrier : Carrier): {Engine.Entity}
getVehicles: function(): {Engine.Entity}
getRunningCost: function(vehicleEntity : Engine.Entity): number
getDepreciatedValue: function(vehicleEntity : Engine.Entity): integer
getPartPrice: function(part : TransportVehiclePart): integer
getLength: function(modelAsset : Model): number
getAllCargoForCargoTypeSet: function(cargoTypeSet : CargoTypeSet): {CargoTypeId}
getVehicleLoadedCargoTypes: function(vehicleEntity : Engine.Entity): {CargoTypeId}
getVehicleProblems: function(): {{{Engine.Entity}, VehicleProblem}}
getMaintenanceEmissionPenalty: function(maintenanceState : number): number
getMaintenanceComfortPenalty: function(maintenanceState : number): number
getMaintenanceTopSpeedPenalty: function(topSpeedMaintenanceFactorPenaltyPerLevel : number, maintenanceState : number): number
getMaintenanceRunningCostPenalty: function(maintenanceState : number): number
getVehicleType: function(vehicleEntity : Engine.Entity): integer
getVehicleCapacities: function(vehicleEntity : Engine.Entity): {integer}
getVehicleUnsetCapacities: function(vehicleEntity : Engine.Entity): {{integer}}
end
```
### UtilVehicle.findBestLineAndDepotForVehicle[🔗](#$api.engine.util~UtilVehicle.findBestLineAndDepotForVehicle)
```
function UtilVehicle.findBestLineAndDepotForVehicle(vehicleEntity : Engine.Entity): {Engine.Entity, Engine.Entity}
```
Searches the best line and depot for the vehicle
**Parameters**
* `vehicleEntity` :`Engine.Entity` — the vehicle for which to search the best line and depot
**Returns**
1. `{Engine.Entity, Engine.Entity}` — line and depot entities, if found
### UtilVehicle.findBestDepotForLine[🔗](#$api.engine.util~UtilVehicle.findBestDepotForLine)
```
function UtilVehicle.findBestDepotForLine(carrier : Carrier, transportModes : {TransportMode}, lineEntity : Engine.Entity, position : Vec3f): Engine.Entity
```
Searches the best depot for the line or position (in case of air vehicles)
**Parameters**
* `carrier` :`Carrier` — the carrier to search for
* `transportModes` :`{TransportMode}` — the transport modes to check for connectivity
* `lineEntity` :`Engine.Entity` — the line to search the depot for
* `position` :`Vec3f` — the position from which to search (air/water vehicles only)
**Returns**
1. `Engine.Entity` — best depot, if any
### UtilVehicle.getSpeed[🔗](#$api.engine.util~UtilVehicle.getSpeed)
```
function UtilVehicle.getSpeed(vehicleEntity : Engine.Entity): number
```
Get speed of the vehicle
**Parameters**
* `vehicleEntity` :`Engine.Entity` — vehicle entity
**Returns**
1. `number` — speed
### UtilVehicle.getPosition[🔗](#$api.engine.util~UtilVehicle.getPosition)
```
function UtilVehicle.getPosition(vehicleEntity : Engine.Entity): Vec3f
```
Get the position of the vehicle
**Parameters**
* `vehicleEntity` :`Engine.Entity` — vehicle entity
**Returns**
1. `Vec3f` — world position
### UtilVehicle.calcPathPosData[🔗](#$api.engine.util~UtilVehicle.calcPathPosData)
```
function UtilVehicle.calcPathPosData(vehicleEntity : Engine.Entity): PathPosData
```
Get the position, direction and curvature of the vehicle
**Parameters**
* `vehicleEntity` :`Engine.Entity` — vehicle entity
**Returns**
1. `PathPosData` — position and direction information for the vehicle
### UtilVehicle.getDirection[🔗](#$api.engine.util~UtilVehicle.getDirection)
```
function UtilVehicle.getDirection(vehicleEntity : Engine.Entity): Vec3f
```
Get the direction of the vehicle
**Parameters**
* `vehicleEntity` :`Engine.Entity` — vehicle entity
**Returns**
1. `Vec3f` — direction
### UtilVehicle.getVehiclesByCarrier[🔗](#$api.engine.util~UtilVehicle.getVehiclesByCarrier)
```
function UtilVehicle.getVehiclesByCarrier(carrier : Carrier): {Engine.Entity}
```
Gets all vehicles using by a given carrier
**Parameters**
* `carrier` :`Carrier` — kind of carrier
**Returns**
1. `{Engine.Entity}` — list of vehicle entities
### UtilVehicle.getVehicles[🔗](#$api.engine.util~UtilVehicle.getVehicles)
```
function UtilVehicle.getVehicles(): {Engine.Entity}
```
Gets all vehicles
**Returns**
1. `{Engine.Entity}` — list of vehicle entities
### UtilVehicle.getRunningCost[🔗](#$api.engine.util~UtilVehicle.getRunningCost)
```
function UtilVehicle.getRunningCost(vehicleEntity : Engine.Entity): number
```
Get running cost of the vehicle per year
**Parameters**
* `vehicleEntity` :`Engine.Entity` — vehicle entity
**Returns**
1. `number` — running cost
### UtilVehicle.getDepreciatedValue[🔗](#$api.engine.util~UtilVehicle.getDepreciatedValue)
```
function UtilVehicle.getDepreciatedValue(vehicleEntity : Engine.Entity): integer
```
Get vehicle depreciated value
**Parameters**
* `vehicleEntity` :`Engine.Entity` — vehicle entity
**Returns**
1. `integer` — depreciated value
### UtilVehicle.getPartPrice[🔗](#$api.engine.util~UtilVehicle.getPartPrice)
```
function UtilVehicle.getPartPrice(part : TransportVehiclePart): integer
```
Get vehicle part value
**Parameters**
* `part` :`TransportVehiclePart` — transport vehicle part
**Returns**
1. `integer` — value
### UtilVehicle.getLength[🔗](#$api.engine.util~UtilVehicle.getLength)
```
function UtilVehicle.getLength(modelAsset : Model): number
```
Get length of the vehicle model
**Parameters**
* `modelAsset` :`Model` — model asset
**Returns**
1. `number` — length
### UtilVehicle.getAllCargoForCargoTypeSet[🔗](#$api.engine.util~UtilVehicle.getAllCargoForCargoTypeSet)
```
function UtilVehicle.getAllCargoForCargoTypeSet(cargoTypeSet : CargoTypeSet): {CargoTypeId}
```
Get cargo in CargoTypeSet
**Parameters**
* `cargoTypeSet` :`CargoTypeSet` — cargo type set
**Returns**
1. `{CargoTypeId}` — CargoTypeId in the set
### UtilVehicle.getVehicleLoadedCargoTypes[🔗](#$api.engine.util~UtilVehicle.getVehicleLoadedCargoTypes)
```
function UtilVehicle.getVehicleLoadedCargoTypes(vehicleEntity : Engine.Entity): {CargoTypeId}
```
Get list of cargo types loaded in the vehicle
**Parameters**
* `vehicleEntity` :`Engine.Entity` — vehicle entity
**Returns**
1. `{CargoTypeId}` — list of cargo types loaded in the vehicle
### UtilVehicle.getVehicleProblems[🔗](#$api.engine.util~UtilVehicle.getVehicleProblems)
```
function UtilVehicle.getVehicleProblems(): {{{Engine.Entity}, VehicleProblem}}
```
Get vehicles with problems
**Returns**
1. `{{{Engine.Entity}, VehicleProblem}}` — vehicle entity and problem
### UtilVehicle.getMaintenanceEmissionPenalty[🔗](#$api.engine.util~UtilVehicle.getMaintenanceEmissionPenalty)
```
function UtilVehicle.getMaintenanceEmissionPenalty(maintenanceState : number): number
```
Get vehicle emission penalty in percent
**Parameters**
* `maintenanceState` :`number` — maintenance state
**Returns**
1. `number` — emission penalty in percent
### UtilVehicle.getMaintenanceComfortPenalty[🔗](#$api.engine.util~UtilVehicle.getMaintenanceComfortPenalty)
```
function UtilVehicle.getMaintenanceComfortPenalty(maintenanceState : number): number
```
Get vehicle comfort penalty in percent
**Parameters**
* `maintenanceState` :`number` — maintenance state
**Returns**
1. `number` — comfort penalty in percent
### UtilVehicle.getMaintenanceTopSpeedPenalty[🔗](#$api.engine.util~UtilVehicle.getMaintenanceTopSpeedPenalty)
```
function UtilVehicle.getMaintenanceTopSpeedPenalty(topSpeedMaintenanceFactorPenaltyPerLevel : number, maintenanceState : number): number
```
Get vehicle top speed penalty in percent
**Parameters**
* `topSpeedMaintenanceFactorPenaltyPerLevel` :`number` — penalty factor per level
* `maintenanceState` :`number` — maintenance state
**Returns**
1. `number` — top speed penalty in percent
### UtilVehicle.getMaintenanceRunningCostPenalty[🔗](#$api.engine.util~UtilVehicle.getMaintenanceRunningCostPenalty)
```
function UtilVehicle.getMaintenanceRunningCostPenalty(maintenanceState : number): number
```
Get vehicle running cost penalty in percent
**Parameters**
* `maintenanceState` :`number` — maintenance state
**Returns**
1. `number` — running cost penalty in percent
### UtilVehicle.getVehicleType[🔗](#$api.engine.util~UtilVehicle.getVehicleType)
```
function UtilVehicle.getVehicleType(vehicleEntity : Engine.Entity): integer
```
Get the vehicle's type
**Parameters**
* `vehicleEntity` :`Engine.Entity` — vehicle entity
**Returns**
1. `integer` — vehicle type
### UtilVehicle.getVehicleCapacities[🔗](#$api.engine.util~UtilVehicle.getVehicleCapacities)
```
function UtilVehicle.getVehicleCapacities(vehicleEntity : Engine.Entity): {integer}
```
Get vehicle capacities
**Parameters**
* `vehicleEntity` :`Engine.Entity` — vehicle entity
**Returns**
1. `{integer}` — vehicle capacities
### UtilVehicle.getVehicleUnsetCapacities[🔗](#$api.engine.util~UtilVehicle.getVehicleUnsetCapacities)
```
function UtilVehicle.getVehicleUnsetCapacities(vehicleEntity : Engine.Entity): {{integer}}
```
Get vehicle unset capacities
**Parameters**
* `vehicleEntity` :`Engine.Entity` — vehicle entity
**Returns**
1. `{{integer}}` — vehicle unset capacities for each unset capacity