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

136 KiB

index / api / engine / util


Module 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🔗

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🔗

function EngineUtil.getPlayer(): Engine.Entity

Obtains the player entity.

Returns

  1. Engine.Entity — entity id

EngineUtil.getWorld🔗

function EngineUtil.getWorld(): Engine.Entity

Obtains the world entity.

Returns

  1. Engine.Entity — entity id

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🔗

function EngineUtil.getYear(): integer

Returns

  1. integer

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🔗

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🔗

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🔗

EngineUtil.cargo: UtilCargo

EngineUtil.construction🔗

EngineUtil.construction: UtilConstruction

EngineUtil.chart🔗

EngineUtil.chart: UtilChart

EngineUtil.finance🔗

EngineUtil.finance: UtilFinance

EngineUtil.headquarters🔗

EngineUtil.headquarters: UtilHeadquarters

EngineUtil.line🔗

EngineUtil.line: UtilLine

EngineUtil.logbook🔗

EngineUtil.logbook: UtilLogbook

EngineUtil.maintenance🔗

EngineUtil.maintenance: UtilMaintenance

EngineUtil.octree🔗

EngineUtil.octree: UtilOctree

EngineUtil.parallelStrip🔗

EngineUtil.parallelStrip: UtilParallelStrip

EngineUtil.pathfinding🔗

EngineUtil.pathfinding: UtilPathfinding

EngineUtil.station🔗

EngineUtil.station: UtilStation

EngineUtil.stock🔗

EngineUtil.stock: UtilStock

EngineUtil.town🔗

EngineUtil.town: UtilTown

EngineUtil.transport🔗

EngineUtil.transport: UtilTransport

EngineUtil.vehicle🔗

EngineUtil.vehicle: UtilVehicle

EngineUtil.industry🔗

EngineUtil.industry: UtilIndustry

EngineUtil.proposal🔗

EngineUtil.proposal: UtilProposal

EngineUtil.emission🔗

EngineUtil.emission: UtilEmission

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🔗

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🔗

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🔗

record UtilCargo.CargoQualityData  clone: function(CargoQualityData): CargoQualityData
  countBad: integer
  countTotal: integer
  averageQuality: number | nil
  isVeryBad: boolean
end

UtilCargo.CargoQualityData.clone🔗

function UtilCargo.CargoQualityData.clone(CargoQualityData): CargoQualityData

Parameters

  • CargoQualityData

Returns

  1. CargoQualityData

UtilCargo.CargoQualityData.countBad🔗

UtilCargo.CargoQualityData.countBad: integer

UtilCargo.CargoQualityData.countTotal🔗

UtilCargo.CargoQualityData.countTotal: integer

UtilCargo.CargoQualityData.averageQuality🔗

UtilCargo.CargoQualityData.averageQuality: number | nil

UtilCargo.CargoQualityData.isVeryBad🔗

UtilCargo.CargoQualityData.isVeryBad: boolean

UtilCargo.SummarizedCargoQualityData🔗

record UtilCargo.SummarizedCargoQualityData  clone: function(SummarizedCargoQualityData): SummarizedCargoQualityData
  passengers: CargoQualityData
  cargo: CargoQualityData
end

UtilCargo.SummarizedCargoQualityData.clone🔗

function UtilCargo.SummarizedCargoQualityData.clone(SummarizedCargoQualityData): SummarizedCargoQualityData

Parameters

  • SummarizedCargoQualityData

Returns

  1. SummarizedCargoQualityData

UtilCargo.SummarizedCargoQualityData.passengers🔗

UtilCargo.SummarizedCargoQualityData.passengers: CargoQualityData

UtilCargo.SummarizedCargoQualityData.cargo🔗

UtilCargo.SummarizedCargoQualityData.cargo: CargoQualityData

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

global record UtilChart  getChartLabel: function(config : ChartConfig, index : integer, abbreviated : boolean): string
  setLastValue: function(chartResult : ChartResult, series : integer, value : number)
end

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

function UtilConstruction.getGlobalConstructionParams(): {string : number}

Get global construction params

Returns

  1. {string : number} — global construction parameters

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

global record UtilHeadquarters  getTransportedData: function(): TransportationStats
  getCompaniesValue: function(): CompanyValue
end

UtilHeadquarters.getTransportedData🔗

function UtilHeadquarters.getTransportedData(): TransportationStats

Obtains the transportation data.

Returns

  1. TransportationStats — some transportation statistics for the company

UtilHeadquarters.getCompaniesValue🔗

function UtilHeadquarters.getCompaniesValue(): CompanyValue

Obtains the companie's value

Returns

  1. CompanyValue — company value data

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🔗

record UtilIndustry.IndustryProductivityInfo  producing: boolean
  boostFromRule: boolean
  boostFromPersonCapacity: boolean
end

UtilIndustry.IndustryProductivityInfo.producing🔗

UtilIndustry.IndustryProductivityInfo.producing: boolean

UtilIndustry.IndustryProductivityInfo.boostFromRule🔗

UtilIndustry.IndustryProductivityInfo.boostFromRule: boolean

UtilIndustry.IndustryProductivityInfo.boostFromPersonCapacity🔗

UtilIndustry.IndustryProductivityInfo.boostFromPersonCapacity: boolean

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🔗

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🔗

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🔗

[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🔗

record UtilLine.LineCapacityUsage  used: number
  capacity: number
end

UtilLine.LineCapacityUsage.used🔗

UtilLine.LineCapacityUsage.used: number

Currently used capacity

UtilLine.LineCapacityUsage.capacity🔗

UtilLine.LineCapacityUsage.capacity: number

Total capacity

UtilLine.PathProblemLocation🔗

record UtilLine.PathProblemLocation  edgeIndex: integer
  node: NodeId
  nodePosition: Vec3f
  okModes: {TransportMode : boolean}
  relaxedModes: {TransportMode : boolean}
  allowedModes: {TransportMode : boolean}
end

UtilLine.PathProblemLocation.edgeIndex🔗

UtilLine.PathProblemLocation.edgeIndex: integer

UtilLine.PathProblemLocation.node🔗

UtilLine.PathProblemLocation.node: NodeId

UtilLine.PathProblemLocation.nodePosition🔗

UtilLine.PathProblemLocation.nodePosition: Vec3f

UtilLine.PathProblemLocation.okModes🔗

UtilLine.PathProblemLocation.okModes: {TransportMode : boolean}

compatible transport modes present on the last compatible edge (e.g. ELECTRIC_TRAIN)

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🔗

UtilLine.PathProblemLocation.allowedModes: {TransportMode : boolean}

Allowed modes for the line / vehicle in general

UtilLine.TerminalCapacityUsage🔗

record UtilLine.TerminalCapacityUsage  equals: function(TerminalCapacityUsage, TerminalCapacityUsage): boolean
  used: number
  capacity: number
end

UtilLine.TerminalCapacityUsage.equals🔗

function UtilLine.TerminalCapacityUsage.equals(TerminalCapacityUsage, TerminalCapacityUsage): boolean

Parameters

  • TerminalCapacityUsage
  • TerminalCapacityUsage

Returns

  1. boolean

UtilLine.TerminalCapacityUsage.used🔗

UtilLine.TerminalCapacityUsage.used: number

Currently used capacity

UtilLine.TerminalCapacityUsage.capacity🔗

UtilLine.TerminalCapacityUsage.capacity: number

Total capacity

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🔗

UtilLine.StopState.empty: boolean

No vehicles and less than 2 stops

UtilLine.StopState.noPath🔗

UtilLine.StopState.noPath: boolean

No path between stops

UtilLine.StopState.noPathFromAlternative🔗

UtilLine.StopState.noPathFromAlternative: {integer, PathProblemLocation}

No path from an alternative stop {flattenedTerminalIndex, optional problem location}

UtilLine.StopState.noPathToAlternative🔗

UtilLine.StopState.noPathToAlternative: {integer, PathProblemLocation}

No path to an alternative stop {flattenedTerminalIndex, optional problem location}

UtilLine.StopState.duplicateStop🔗

UtilLine.StopState.duplicateStop: boolean

Stop is a duplicate

UtilLine.StopState.incompatibleStop🔗

UtilLine.StopState.incompatibleStop: boolean

Stop is incompatible with the line's transport mode

UtilLine.StopState.noPathLocation🔗

UtilLine.StopState.noPathLocation: PathProblemLocation

Optional problem location in case of noPath

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🔗

function UtilLine.calcLineStationThroughput(lineEntity : Engine.Entity): integer

Calc line throughput

Parameters

  • lineEntity :Engine.Entity — line entity

Returns

  1. integer — throughput value

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

function UtilLine.getNoRoadConnectionProblems(): {Engine.Entity}

Get nodes (construction entities) without any road connection

Returns

  1. {Engine.Entity} — list of node entities

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

global record UtilMaintenance  calcMaintenanceForStationGroup: function(stationGroupEntity : Engine.Entity): integer
  calcMaintenanceForSubconstruction: function(subconstructionEntity : Engine.Entity): integer
end

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

[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🔗

record UtilParallelStrip.StripInfo  carrier: Carrier
  edgeType: BaseEdgeType
  edgeTypeIndex: integer
end

UtilParallelStrip.StripInfo.carrier🔗

UtilParallelStrip.StripInfo.carrier: Carrier

UtilParallelStrip.StripInfo.edgeType🔗

UtilParallelStrip.StripInfo.edgeType: BaseEdgeType

UtilParallelStrip.StripInfo.edgeTypeIndex🔗

UtilParallelStrip.StripInfo.edgeTypeIndex: integer

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🔗

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🔗

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🔗

[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🔗

record UtilPathfinding.EdgeIdDirAndLength  edgeId: EdgeId
  dir: boolean
  length: number
  new: function(EdgeId, boolean, number): EdgeIdDirAndLength
end

UtilPathfinding.EdgeIdDirAndLength.edgeId🔗

UtilPathfinding.EdgeIdDirAndLength.edgeId: EdgeId

Edge ID

UtilPathfinding.EdgeIdDirAndLength.dir🔗

UtilPathfinding.EdgeIdDirAndLength.dir: boolean

Direction

UtilPathfinding.EdgeIdDirAndLength.length🔗

UtilPathfinding.EdgeIdDirAndLength.length: number

Length

UtilPathfinding.EdgeIdDirAndLength.new🔗

function UtilPathfinding.EdgeIdDirAndLength.new(EdgeId, boolean, number): EdgeIdDirAndLength

Generates a new item.

Parameters

  • EdgeId
  • boolean
  • number

Returns

  1. EdgeIdDirAndLength

UtilPathfinding.EdgeIdDir🔗

record UtilPathfinding.EdgeIdDir  edgeId: EdgeId
  dir: boolean
  new: function(EdgeId, boolean): EdgeIdDir
end

UtilPathfinding.EdgeIdDir.edgeId🔗

UtilPathfinding.EdgeIdDir.edgeId: EdgeId

Edge ID

UtilPathfinding.EdgeIdDir.dir🔗

UtilPathfinding.EdgeIdDir.dir: boolean

Direction

UtilPathfinding.EdgeIdDir.new🔗

function UtilPathfinding.EdgeIdDir.new(EdgeId, boolean): EdgeIdDir

Generates a new item.

Parameters

  • EdgeId
  • boolean

Returns

  1. EdgeIdDir

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🔗

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🔗

function UtilPathfinding.getTargetsByLandUse(): {<any type> : <any type>}

Returns

  1. {<any type> : <any type>}

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🔗

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🔗

function UtilProposal.makeProposalData(Proposal, Context): ProposalData

Parameters

  • Proposal
  • Context

Returns

  1. ProposalData

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

function UtilProposal.createSubconstructionLotList(Proposal.Subconstruction, Mat4f): Engine.Component.LotList

Parameters

  • Proposal.Subconstruction
  • Mat4f

Returns

  1. Engine.Component.LotList

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🔗

[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🔗

record UtilStation.StationUsage  totalUsed: integer
  overflow: integer
  poolCapacity: integer
  terminalCapacity: integer
end

UtilStation.StationUsage.totalUsed🔗

UtilStation.StationUsage.totalUsed: integer

UtilStation.StationUsage.overflow🔗

UtilStation.StationUsage.overflow: integer

UtilStation.StationUsage.poolCapacity🔗

UtilStation.StationUsage.poolCapacity: integer

UtilStation.StationUsage.terminalCapacity🔗

UtilStation.StationUsage.terminalCapacity: integer

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🔗

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🔗

record UtilStation.StationGroupCapacityUsage  equals: function(StationGroupCapacityUsage, StationGroupCapacityUsage): boolean
  capacity: integer
  waitingHallCapacity: integer
  used: integer
  overflow: boolean
end

UtilStation.StationGroupCapacityUsage.equals🔗

function UtilStation.StationGroupCapacityUsage.equals(StationGroupCapacityUsage, StationGroupCapacityUsage): boolean

Parameters

  • StationGroupCapacityUsage
  • StationGroupCapacityUsage

Returns

  1. boolean

UtilStation.StationGroupCapacityUsage.capacity🔗

UtilStation.StationGroupCapacityUsage.capacity: integer

UtilStation.StationGroupCapacityUsage.waitingHallCapacity🔗

UtilStation.StationGroupCapacityUsage.waitingHallCapacity: integer

UtilStation.StationGroupCapacityUsage.used🔗

UtilStation.StationGroupCapacityUsage.used: integer

UtilStation.StationGroupCapacityUsage.overflow🔗

UtilStation.StationGroupCapacityUsage.overflow: boolean

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

function UtilStock.getProductionRating(stockListEntity : Engine.Entity): number

Get stocklist production rating

Parameters

  • stockListEntity :Engine.Entity — list entity

Returns

  1. number — production rating

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🔗

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🔗

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🔗

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🔗

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🔗

[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🔗

record UtilTown.TownReachability  commercialPrivate: integer
  commercialPublic: integer
  industrialPrivate: integer
  industrialPublic: integer
end

UtilTown.TownReachability.commercialPrivate🔗

UtilTown.TownReachability.commercialPrivate: integer

UtilTown.TownReachability.commercialPublic🔗

UtilTown.TownReachability.commercialPublic: integer

UtilTown.TownReachability.industrialPrivate🔗

UtilTown.TownReachability.industrialPrivate: integer

UtilTown.TownReachability.industrialPublic🔗

UtilTown.TownReachability.industrialPublic: integer

UtilTown.TownCapacityUsage🔗

record UtilTown.TownCapacityUsage  used: integer
  capacity: integer
end

UtilTown.TownCapacityUsage.used🔗

UtilTown.TownCapacityUsage.used: integer

UtilTown.TownCapacityUsage.capacity🔗

UtilTown.TownCapacityUsage.capacity: integer

UtilTown.TownEmission🔗

record UtilTown.TownEmission  noise: number
  pollution: number
  areaSquareKm: number
end

UtilTown.TownEmission.noise🔗

UtilTown.TownEmission.noise: number

UtilTown.TownEmission.pollution🔗

UtilTown.TownEmission.pollution: number

UtilTown.TownEmission.areaSquareKm🔗

UtilTown.TownEmission.areaSquareKm: number

UtilTown.DestinationUseCount🔗

record UtilTown.DestinationUseCount  count: integer
  linesUseCount: integer
end

UtilTown.DestinationUseCount.count🔗

UtilTown.DestinationUseCount.count: integer

UtilTown.DestinationUseCount.linesUseCount🔗

UtilTown.DestinationUseCount.linesUseCount: integer

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🔗

record UtilTown.TownHappinessStats.ByResident  resident: {integer, integer}
  nonResident: {integer, integer}
end

UtilTown.TownHappinessStats.ByResident.resident🔗

UtilTown.TownHappinessStats.ByResident.resident: {integer, integer}

UtilTown.TownHappinessStats.ByResident.nonResident🔗

UtilTown.TownHappinessStats.ByResident.nonResident: {integer, integer}

UtilTown.TownHappinessStats.travellingInside🔗

UtilTown.TownHappinessStats.travellingInside: {integer, integer}

UtilTown.TownHappinessStats.travellingTo🔗

UtilTown.TownHappinessStats.travellingTo: ByResident

UtilTown.TownHappinessStats.travellingFrom🔗

UtilTown.TownHappinessStats.travellingFrom: ByResident

UtilTown.TownHappinessStats.atBuilding🔗

UtilTown.TownHappinessStats.atBuilding: {integer, integer}

UtilTown.TownHappinessStats.byCar🔗

UtilTown.TownHappinessStats.byCar: {integer, integer}

UtilTown.TownHappinessStats.walking🔗

UtilTown.TownHappinessStats.walking: {integer, integer}

UtilTown.TownHappinessStats.byLine🔗

UtilTown.TownHappinessStats.byLine: {{Engine.Entity, ByResident}}

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🔗

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🔗

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🔗

function UtilTown.getLandUse2CargoTypes(): {LandUseType : {CargoTypeId}}

Get town available cargo needs

Returns

  1. {LandUseType : {CargoTypeId}} — map of land use to cargo types

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

function UtilTown.getTownProblems(): {{{Engine.Entity}, TownProblem}}

Get towns with problems

Returns

  1. {{{Engine.Entity}, TownProblem}} — town entity and problem

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

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🔗

function UtilVehicle.getSpeed(vehicleEntity : Engine.Entity): number

Get speed of the vehicle

Parameters

  • vehicleEntity :Engine.Entity — vehicle entity

Returns

  1. number — speed

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🔗

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🔗

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🔗

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🔗

function UtilVehicle.getVehicles(): {Engine.Entity}

Gets all vehicles

Returns

  1. {Engine.Entity} — list of vehicle entities

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🔗

function UtilVehicle.getDepreciatedValue(vehicleEntity : Engine.Entity): integer

Get vehicle depreciated value

Parameters

  • vehicleEntity :Engine.Entity — vehicle entity

Returns

  1. integer — depreciated value

UtilVehicle.getPartPrice🔗

function UtilVehicle.getPartPrice(part : TransportVehiclePart): integer

Get vehicle part value

Parameters

  • part :TransportVehiclePart — transport vehicle part

Returns

  1. integer — value

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🔗

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🔗

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🔗

function UtilVehicle.getVehicleProblems(): {{{Engine.Entity}, VehicleProblem}}

Get vehicles with problems

Returns

  1. {{{Engine.Entity}, VehicleProblem}} — vehicle entity and problem

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🔗

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🔗

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🔗

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🔗

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🔗

function UtilVehicle.getVehicleCapacities(vehicleEntity : Engine.Entity): {integer}

Get vehicle capacities

Parameters

  • vehicleEntity :Engine.Entity — vehicle entity

Returns

  1. {integer} — vehicle capacities

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