Module api.engine
Contains API for reading the game engine state.
This module is available as read-only access to the entire engine state (in particular to the
entire entity component system). It can be accessed from both the GUI State and the Engine State.
system |
Contains all systems. |
util |
Contains extra utility functions that require the engine. |
getStrips(edgeEntity) |
Obtains all parallel strips of a base edge entity (there might be more than one parallel strip for each base edge). |
getEdge2stationsMap() |
Obtains a map mapping transport network edges to stations that can be reached from that edge. |
getStation2edgesMap() |
Obtains a map mapping stations to all reachable edges from that station (the actual catchment area of the station). |
getStation2stationsAndDistancesMap() |
Obtains a map, mapping station to all reachable stations in the catchment area, and, additionally, the distance of the
shortest path. |
Revision |
Keeps track of modifications to entities. |
Functions
-
entityExists(entity)
-
Checks whether an entity exists
Parameters:
-
forEachEntity(callback)
-
Loop over each entity in the engine
Parameters:
- callback
function(Entity)
the callback called for each entity
-
forEachEntityWithComponent(Userdata, componentType)
-
Loop over each entity with a given component
Parameters:
- Userdata
function(Entity,
) fn the callback called for each entity with the given component
- componentType
ComponentType
the component used to filter the entities
-
getComponent(entity, type)
-
Obtains a component from an entity, if available.
The returned entity (if any) is a Component.
Parameters:
- entity
Entity
the entity (must be a valid, existing entity)
- type
api.type.ComponentType
the component type to obtain
Returns:
Object
returns the component if the entity has one, or nil otherwise.
-
getRevision(entity)
-
Returns the revision of the entity.
Parameters:
Tables
-
system
-
Contains all systems. Systems manage the behaviour of entities and contain extra cached information about entities.
-
util
-
Contains extra utility functions that require the engine.
Animal Move System
system.animalSystem
Manages animals.
-
forEach(fn)
-
Loops over all animals.
Parameters:
- fn
func(Entity,)
a callback with arguments: the entity and the components
Aircraft Move System
system.aircraftMoveSystem
System managing the movement of airplanes.
-
forEach(fn)
-
Loops over all aircraft.
Parameters:
- fn
func(Entity,)
a callback with arguments: the entity and the components
-
getAirCraftInfo(vehicleEntity)
-
Obtains Aircraft information for the given entity.
Parameters:
- vehicleEntity
Entity
the entity id of the aircraft that should be inspected
Returns:
type.AircraftInfo
-
isReserved(edgeId)
-
Checks if a given edge is reserved by an aircraft.
Parameters:
Returns:
bool
true if reserved
Base Parallel Strip System
system.baseParallelStripSystem
Contain information about parallel edge ranges.
-
getStrips(edgeEntity)
-
Obtains all parallel strips of a base edge entity (there might be more than one parallel strip for each base edge).
Parameters:
- edgeEntity
Entity
the entity of the edge that should be inspected
Returns:
{Entity,...}
Catchment Area System
system.catchmentAreaSystem
Contains cached information about reachability of stations and destinations.
-
getEdge2stationsMap()
-
Obtains a map mapping transport network edges to stations that can be reached from that edge.
Returns:
{[type.EdgeId]={{Entity,int},...},...}
-
getStation2edgesMap()
-
Obtains a map mapping stations to all reachable edges from that station (the actual catchment area of the station).
Returns:
{[Entity]={{type.EdgeId,int},...},...}
-
getStation2stationsAndDistancesMap()
-
Obtains a map, mapping station to all reachable stations in the catchment area, and, additionally, the distance of the
shortest path.
Returns:
{[Entity]={{Entity,int},...},...}
Line System
system.lineSystem
Contains cached information about lines.
-
getLineStops(stationGroupEntity)
-
Gets all lines stopping at a station group.
Parameters:
- stationGroupEntity
Entity
the stationGroup for which the lines should be fetched
Returns:
{{Entity,int},...}
-
getLineStopsForStation(stationEntity)
-
Gets all lines stopping at a station.
Parameters:
- stationEntity
Entity
the station for which the lines should be fetched
Returns:
{{Entity,int},...}
-
getLineStopsForTerminal(stationEntity, terminal)
-
Gets all lines stopping at a terminal.
Parameters:
- stationEntity
Entity
the station for which the lines should be fetched
- terminal
int
the terminal of the station for which the lines should be fetched
Returns:
{{Entity,int},...}
-
getLines()
-
Gets all lines on the map.
Returns:
{Entity,...}
-
getLinesForPlayer(playerEntity)
-
Gets all lines belonging to the player.
Parameters:
- playerEntity
Entity
the player for which the lines should be fetched
Returns:
{Entity,...}
-
getLinesForWaypoint(waypointEntity)
-
Gets all lines going through a waypoint.
Parameters:
- waypointEntity
Entity
the waypoint for which the lines should be fetched
Returns:
{Entity,...}
-
getProblemLines(playerEntity)
-
Gets all lines having an issue, and the issue in question.
Parameters:
- playerEntity
Entity
the player for which the lines should be fetched
Returns:
{{Entity,type.LineProblem},...}
-
getStationGroup2LineStopsMap()
-
Gets all stops in a station group.
Returns:
{[Entity]={{Entity,int},...},...}
-
getTerminal2lineStops()
-
Gets all stops in a terminal.
Returns:
{[{Entity,int}]={{Entity,int},...},...}
Railroad Crossing System
system.railRoadCrossingSystem
Contains information about raiload crossings.
-
getRailroadCrossingForEdge(edgeEntity)
-
Gets all railroad crossings of the given base edge entity.
Parameters:
- edgeEntity
Entity
the entity id of the edge that should be inspected
Returns:
Entity
-
getRailroadCrossingForNode(nodeEntity)
-
Gets all railroad crossings of the given base node entity.
Parameters:
- nodeEntity
Entity
the entity id of the node that should be inspected
Returns:
Entity
River System
system.riverSystem
Contains information about water in the map.
-
getWaterMeshEntities(tile0, tile1)
-
Gets all water meshes within the bounds.
Parameters:
Returns:
{Entity,...}
Runway System
system.runwaySystem
Contains information about runway edges.
-
getLandingNodeIdMap()
-
Gets all stations reachable from that landing node.
Returns:
{[type.NodeId]=Entity,...}
-
getTakeoffNodeIdMap()
-
Gets all station from which the takeoff node can reached.
Returns:
{[type.NodeId]=Entity,...}
Ship Move System
system.shipMoveSystem
Contains information about the movement of ships.
-
forEach(fn)
-
Loops over all ships.
Parameters:
- fn
func(Entity,)
a callback with arguments: the entity and the components
-
getShipInfo(vehicleEntity)
-
Gets more path and movement information about ships.
Parameters:
- vehicleEntity
Entity
the entity id of the ship that should be inspected
Returns:
type.ShipInfo
Signal System
system.signalSystem
Contains information about Signals (waypoints, path and one way signals)
-
getSignal(edgeId, reversed)
-
Gets the signal from an api.type.EdgeId at the given direction.
Notice: there can be at most one signal per direction per transport network edge.
Parameters:
- edgeId
type.EdgeId
the id of the edge hosting the signal
- reversed
bool
false if signal in direction of edge is requested
Returns:
type.SignalId
Cargo At Terminal System
system.simCargoAtTerminalSystem
Contains information about cargo that is waiting at the station.
-
getCount(edgeId, cargoType)
-
Counts amount of cargo present at the given transport network edge.
Parameters:
- edgeId
type.EdgeId
the id of the edge that should be inspected
- cargoType
type.cargoType
the cargo type that should be counted
Returns:
int
the number of items counted
-
getEntity(edgeId, cargoType)
-
Gets one (random) entity from the cargo waiting
Parameters:
- edgeId
type.EdgeId
the id of the edge that should be inspected
- cargoType
type.cargoType
the cargo type that should be counted
Returns:
Entity
the entity id of a random waiting cargo item of the given type
-
getMaxCount(edgeId, cargoType)
-
Counts maximal amount of cargo present at the given transport network edge.
Parameters:
- edgeId
type.EdgeId
the id of the edge that should be inspected
- cargoType
type.cargoType
the cargo type that should be counted
Returns:
int
the maximum number of items counted
-
getPlace(edgeId, cargoType)
-
Obtains and reserves a place for the cargo.
Parameters:
- edgeId
type.EdgeId
the id of the edge that should be inspected
- cargoType
type.cargoType
the cargo type that should be requested for
Returns:
int
-
hasFreePlaces(edgeId, cargoType)
-
Checks if the given transport network edge has free space for the given cargo type.
Parameters:
- edgeId
type.EdgeId
the id of the edge that should be inspected
- cargoType
type.cargoType
the cargo type that should be tested for
Returns:
bool
true if there is free space
-
supportsCargoType(edgeId, cargoType)
-
Checks if the given transport network edge can hold the given cargo type.
Parameters:
- edgeId
type.EdgeId
the id of the edge that should be inspected
- cargoType
type.cargoType
the cargo type that should be tested for
Returns:
bool
true if cargo type is supported
Cargo System
system.simCargoSystem
System managing cargo.
-
getSimCargoAtTerminalForTransportNetwork(tnEntity)
-
Obtains all cargo that is waiting at the terminal.
Parameters:
- tnEntity
Entity
the entity of the transport network
Returns:
{Entity,...}
-
getSimCargoIdleForTransportNetwork(tnEntity)
-
Obtains all cargo that is waiting to be shipped.
Parameters:
- tnEntity
Entity
the entity of the transport network
Returns:
{Entity,...}
-
getSimCargosForLine(lineEntity)
-
Obtains all cargo transported through the given line.
Parameters:
- lineEntity
Entity
the entity of the line
Returns:
{Entity,...}
-
getSimCargosForSource(sourceEntity)
-
Obtains all cargo that was produced by the source.
Parameters:
- sourceEntity
Entity
the entity of the source
Returns:
{Entity,...}
-
getSimCargosForTarget(targetEntity)
-
Obtains all cargo that is trying to reach the target.
Parameters:
- targetEntity
Entity
the entity of the target
Returns:
{Entity,...}
Entity At Stock System
system.simEntityAtStockSystem
System managing cargo produced by industries and waiting.
-
getStock2SimEntityMap()
-
Obtains a map, mapping the stock to the cargo waiting there.
Returns:
{[{Entity,StockId}]
= {Entity,...},...}
-
getStockCount(stockEntity, stockId)
-
Obtains the amount of item waiting at a given stock.
Parameters:
- stockEntity
Entity
the entity of the stock holding entity, e.g. industry
- stockId
StockId
the id of the stock
Returns:
int
-
getStockEntities(stockEntity, stockId)
-
Obtains all entities waiting at a given stock.
Parameters:
- stockEntity
Entity
the entity of the stock holding entity, e.g. industry
- stockId
StockId
the id of the stock
Returns:
{Entity,...}
-
getStockSimEntity(stockEntity, stockId)
-
Obtains the entity that was waiting longest at a given stock.
Parameters:
- stockEntity
Entity
the entity of the stock holding entity, e.g. industry
- stockId
StockId
the id of the stock
Returns:
Entity
Entity At Vehicle System
system.simEntityAtVehicleSystem
System managing entities travelling in a vehicle.
-
getFare()
-
Gets cost of fare.
Returns:
float
the fare
Person At Terminal System
system.simPersonAtTerminalSystem
System managing persons waiting at terminal.
-
getEdgeInfoMap()
-
Gets information about persons waiting at the terminals.
Returns:
{[type.EdgeId]=TerminalInfo}
-
getNumFreePlaces(edgeId)
-
Gets number of free waiting places for the given tranport network edge.
Parameters:
- edgeId
type.EdgeId
the id of the edge that should be inspected
Returns:
int
-
getPos01(edgeId, place)
-
Gets the position on the transport network edge for the given place.
Parameters:
- edgeId
type.EdgeId
the id of the edge that should be inspected
- place
double
the waiting place number
Returns:
{int,int}
the position
Person System
system.simPersonSystem
System managing persons.
-
getCount()
-
Gets number of people on the map.
Returns:
int
number of people
-
getDestination2SpMap()
-
Gets list of people for every destination.
Returns:
{[Entity]={Entity,...},...}
-
getSimPersonsAtTerminalForTransportNetwork(tnEntity)
-
Gets all persons waiting at the given transport network.
Parameters:
- tnEntity
Entity
the entity of the transport network
Returns:
{Entity,...}
-
getSimPersonsForDestination(targetEntity)
-
Gets all persons that have an entity as one of their destination.
Destinations are a home, a work and a shopping destination.
Parameters:
- targetEntity
Entity
the entity of the target
Returns:
{Entity,...}
-
getSimPersonsForLine(lineEntity)
-
Gets all persons travelling with the given line.
Parameters:
- lineEntity
Entity
the entity of the line
Returns:
{Entity,...}
-
getSimPersonsForTarget(targetEntity)
-
Gets all persons currently trying to reach given target.
Parameters:
- targetEntity
Entity
the entity of the target
Returns:
{Entity,...}
-
getSimPersonsIdleForTransportNetwork(tnEntity)
-
Gets all idle persons on a transport network.
Parameters:
- tnEntity
Entity
the entity of the transport network
Returns:
{Entity,...}
-
getSimPersonsMovingForTransportNetwork(tnEntity)
-
Gets all moving persons over a transport network.
Parameters:
- tnEntity
Entity
the entity of the transport network
Returns:
{Entity,...}
Station Group System
system.stationGroupSystem
Manages station groups.
-
getExpiredStationGroups(time)
-
Gets station groups that no longer contain stations and are thus about to be removed.
Parameters:
- time
long
the time stamp until when the stations with this condition are removed
Returns:
{Entity,...}
-
getExpiryProgress(stationGroupEntity, time, time)
-
Gets progress on the removal of station groups.
Parameters:
- stationGroupEntity
Entity
the entity of the station group that is about to be removed
- time
float
the time stamp until when the stations with this condition are removed
- time
float
the time stamp until when the stations with this condition are removed
-
getStationGroup(stationEntity)
-
Obtains the station group to which the station belongs.
Parameters:
- stationEntity
Entity
the entity of the station for which the parent station group is queried
Returns:
Entity
Station System
system.stationSystem
Manages stations.
-
forEach(fn)
-
Loops over all stations.
Parameters:
- fn
func(Entity,)
a callback with arguments: the entity and the components
-
getPersonNodeId2StationTerminalsMap()
-
Gets all transport network nodes associated with a station terminal.
Returns:
{[type.NodeId]
= {{Entity,int},...},...}
-
getStation2TownMap()
-
Gets a map froms stations to towns.
Returns:
{[Entity]
= Entity,...}
-
getStationTerminalForVehicleNode(nodeId)
-
Gets the station terminal to which the node belongs.
Parameters:
- nodeId
type.NodeId
the vehicle node id that is queried for
Returns:
{Entity,int}
-
getStationTerminalsForPersonEdge(edgeId)
-
Gets the station terminals to which the person edge belongs.
Parameters:
Returns:
{{Entity,int},...}
-
getStationTerminalsForPersonNode(nodeId)
-
Gets the station terminals to which the person node belongs.
Parameters:
- nodeId
type.NodeId
the person node id that is queried for
Returns:
{{Entity,int},...}
-
getStations(townEntity)
-
Gets all station in a town.
Parameters:
- townEntity
Entity
the entity of the town that is queried for
Returns:
{Entity,...}
-
getTown(stationEntity)
-
Gets a the town of the station.
Parameters:
- stationEntity
Entity
the entity of the station that is queried for
Returns:
Entity
-
getTown2StationsMap()
-
Gets all station grouped by towns.
Returns:
{[Entity]
= {{Entity},...},...}
-
getVehicleNodeId2StationTerminalsMap()
-
Gets the mapping from vehicle node to station terminal.
Returns:
{[type.NodeId]
= {{Entity,int},...},...}
Stock List System
system.stockListSystem
Manages stocks.
-
getCargoType2stockList2sourceAndCount()
-
Gets all sources and the amount of cargo for a given stock list and a given cargo type.
Returns:
{[Entity]={[Entity]=int,...},...}
-
getSources(destinationEntity)
-
Gets all sources for the destination entity.
Parameters:
- destinationEntity
Entity
the entity for which the sources should be fetched
Returns:
{Entity,...}
Street Connector System
system.streetConnectorSystem
Manages street connections.
-
forEach(fn)
-
Loops over all constructions.
Parameters:
- fn
func(Entity,type.Construction)
Two arguments are passed to fn: the entity and the type.Construction.
-
getConstructionEntityForDepot(depotEntity)
-
Gets all sources for the destination entity.
Parameters:
- depotEntity
Entity
the entity for which the containing construction should be fetched
Returns:
Entity
-
getConstructionEntityForEdge(edgeEntity)
-
Gets the construction that "owns" the given edge.
Parameters:
- edgeEntity
Entity
the entity for which the containing construction should be fetched
Returns:
Entity
-
getConstructionEntityForSimBuilding(industryEntity)
-
Gets the construction for the industry.
Parameters:
- industryEntity
Entity
the entity for which the containing construction should be fetched
Returns:
Entity
-
getConstructionEntityForStation(stationEntity)
-
Gets the construction for the station.
Parameters:
- stationEntity
Entity
the entity for which the containing construction should be fetched
Returns:
Entity
-
getConstructionEntityForTownBuilding(townBuilding)
-
Gets the construction for the town building.
Parameters:
- townBuilding
Entity
the entity for which the containing construction should be fetched
Returns:
Entity
-
getNode2StreetConnectorMap()
-
Gets a mapping from frozen nodes to the construction they belong.
Returns:
{[Entity]=Entity,...}
-
getStation2ConstructionMap()
-
Gets a mapping from stations to constructions.
Returns:
{[Entity]=Entity,...}
-
getStreetConnectorEntity(nodeEntity)
-
Gets the construction to which the node (a frozen node in the construction) belongs.
Parameters:
- nodeEntity
Entity
the entity for which the containing construction should be fetched
Returns:
Entity
Street System
system.streetSystem
Manages base edges.
-
getEdgeForEdgeObject(edgeEntity)
-
Obtains the edge to which the edge object belongs.
Parameters:
- edgeEntity
Entity
the entity of the edge object
Returns:
Entity
-
getEdgeObject2EdgeMap()
-
Obtains the mapping from edge object to edges they belong.
Returns:
{[Entity]=Entity,...}
-
getNode2SegmentMap()
-
Obtains a map from all base nodes to base segments they are connected with.
Returns:
{[Entity]={Entity,...},...}
-
getNode2StreetEdgeMap()
-
Obtains a map from all base nodes to base street segments they are connected with.
Returns:
{[Entity]={Entity,...},...}
-
getNode2TrackEdgeMap()
-
Obtains a map from all base nodes to base track segments they are connected with.
Returns:
{[Entity]={Entity,...},...}
Parcel System
system.parcelSystem
Manages and returns information about parcels.
-
getParcelData(segmentEntity)
-
Obtains all parcels belonging to a segment.
Parameters:
- segmentEntity
Entity
the segment of which to obtain all attached parcels
Returns:
ParcelData
-
getSegment2ParcelData()
-
Obtains a map of all segments to the parcel data of the segment.
Returns:
{[Entity]
= ParcelData, ...}
Town Building System
system.townBuildingSystem
Manages town buildings and parcels.
-
getBuilding(parcelEntity)
-
Obtains the building (if any) that is placed on the given parcel.
Parameters:
- parcelEntity
Entity
the entity of the parcel
Returns:
Entity
-
getCargoSupplyAndLimit(townEntity)
-
Obtains information about towns and cargo.
Parameters:
- townEntity
Entity
the entity of the town
Returns:
{[cargoId]={int,int},...}
-
getLandUsePersonCapacities(townEntity)
-
Obtains information about land use and person capacities.
Parameters:
- townEntity
Entity
the entity of the town
Returns:
{int,int,int}
-
getParcel2BuildingMap()
-
Obtains map from parcel to building occupying the parcel.
Returns:
{[Entity]
= Entity,...}
-
getPersonCapacity2townBuildingMap()
-
Obtains map from person capacities to town buildings.
Returns:
{[Entity]
= Entity,...}
-
getTown2BuildingMap()
-
Obtains map from town to town buildings of the town.
Returns:
{[Entity]
= {Entity,...},...}
-
getTown2personCapacitiesMap()
-
Obtains map from town to person capacities of the town.
Returns:
{[Entity]
= {int,int,int},...}
-
hasBuilding(parcelEntity)
-
Checks if parcel is occupied by building.
Parameters:
- parcelEntity
Entity
the entity of the parcel
Returns:
bool
Transport Network Link System
system.tpNetLinkSystem
Manages transport networks links (small links between roads and constructions).
-
getEdgeId2linkEntities()
-
Gets a map from all edges to the links touching the edge.
Returns:
{[type.EdgeId]
= {Entity,...},...}
-
getLinkEntities(edgeId)
-
Gets all links withing a tranport network edge.
Parameters:
- edgeId
type.EdgeId
the edge id for which the links should be fetched
Returns:
{Entity,...}
Train Move System
system.trainMoveSystem
Manages the movement of trains.
-
forEach(fn)
-
Loops over all trains.
Parameters:
- fn
func(Entity,)
a callback with arguments: the entity and the components
-
getBlockedTrains()
-
Gets all trains that are blocked by another train.
Returns:
{[Entity,Entity],...}
-
getTrainInfo(trainEntity)
-
Gets more information about a train.
Parameters:
- trainEntity
Entity
the entity of the train.
Returns:
type.TrainMoveInfo
-
getVehicleInfo(vehicleEntity)
-
Gets more information about a train carriage/engine.
Parameters:
- vehicleEntity
Entity
the entity of the vehicle.
Returns:
TrainMoveSystem.TrainMoveInfo
Transport History System
system.transportHistorySystem
Keeps a log of some transport-related data.
-
getStationTransportHistoryReferences(stationEntity)
-
Gets more information about the transport history of a station.
Parameters:
- stationEntity
Entity
the entity of the station
Returns:
{Entity}
-
getTargetTransportHistoryReferences(targetEntity)
-
Gets more information about the transport history of a target.
Parameters:
- targetEntity
Entity
the entity of the target, e.g. an industry
Transport Network System
system.transportNetworkSystem
Manages transport networks (and transport network edges and nodes).
-
getIntersections(tnEntity)
-
Gets all intersections within a transport network (e.g. all intersections in a base node).
Parameters:
- tnEntity
Entity
the entity of the transport network
Returns:
{EdgeIsect,...}
-
getTpNetData()
-
Gets a structure representing the graph of the transport network.
Returns:
TpNetData
Transport Vehicle System
system.transportVehicleSystem
Manages the movement and behaviour of transport vehicles. This covers all vehicles transporting cargo and passengers.
-
getGoingToDepotVehicles(depotEntity)
-
Gets all vehicles heading for the depot.
Parameters:
- depotEntity
Entity
the entity of the depot
Returns:
{Entity,...}
-
getInfo(transportVehicleEntity)
-
Gets additional information about the vehicle.
Parameters:
- transportVehicleEntity
Entity
the entity of the transport vehicle
Returns:
{Entity,...}
-
getLine2VehicleMap()
-
Gets a map of lines to the vehicles using the line.
Returns:
{[Entity]={Entity,...},...}
-
getLineVehicles(lineEntity)
-
Gets all vehicles using a given line.
Parameters:
- lineEntity
Entity
the entity of the line
Returns:
{Entity,...}
-
getNoPathVehicles()
-
Gets all vehicles that cannot find a path to their destination.
Returns:
{Entity,...}
-
getNoPathVehicles(carrier)
-
Gets the vehicle names of all vehicles for the given carrier.
Parameters:
- carrier
type.enum.Carrier
the carrier for which the names should be fetched
Returns:
{String,...}
-
getVehicles(tnEntities, wholePath)
-
Gets the vehicle using a certain transport network.
Parameters:
- tnEntities
{Entity,...}
list of transport network entities
- wholePath
bool
true if the vehicle has to use the whole path
-
getVehiclesWithState(state)
-
Gets all vehicles that are in the given state. This can be used, for instance, to obtain a list of all vehicles
currently waiting at a terminal.
Parameters:
- state
type.enum.TransportVehicleState
A state to filter the vehicles
Returns:
{Entity,...}
Vehicle Depot System
system.vehicleDepotSystem
Manages depots and vehicles in depots.
-
forEach(fn)
-
Loops over all depots.
Parameters:
- fn
func(Entity,)
a callback with arguments: the entity and the components
-
getDepotForInNodeId(nodeId)
-
Gets the depot entity to which the node belongs.
Parameters:
- nodeId
type.NodeId
the id of the node for which the depot should be fetched
Returns:
Entity
Octree System
system.octreeSystem
An octree that contains all entities with a bounding box. It enables fast query and location of entities in the map.
-
findIntersectingEntities(box, callback)
-
Fetches all entities in a box and runs a callback for them.
Parameters:
- box
Box3
Box in which all entities are searched.
- callback
func
A function called for each matching entity within box. The callback obtains an entity and a bounding volume.
Entity
-
Revision
-
Keeps track of modifications to entities.
Fields:
Util
-
util.formatAge(time0, time1)
-
Format age of a vehicle using current ingame speed.
Parameters:
- time0
long
begin timestamp of the time interval
- time1
long
end timestamp of the time interval
Returns:
string
formatted output, e.g. "6 years"
-
util.getPlayer()
-
Obtains the player entity.
Returns:
Entity
entity id
-
util.getTransportedData()
-
Obtains the transportation data.
Returns:
usertype
TransportationStats
-
util.getWorld()
-
Obtains the world entity.
Returns:
Entity
entity id
Transport
-
transport.getEndPort(the)
-
Obtains the end connection of this edge
Parameters:
Returns:
type.PortId
PortId at the edge's end
-
transport.getStartPort(edge)
-
Obtains the start connection of this edge
Parameters:
Returns:
type.PortId
PortId at the edge's start
-
transport.isPortLocked(port)
-
Check if a port is locked
Parameters:
Returns:
boolean
true if the port is locked, false otherwise
Pathfinding
-
util.pathfinding.findPath(startingEdgesAndLengths, destinationNodes, transportModeSet, maxLength)
-
Find a path between starting edges and end destination nodes, using a given set of transport modes.
Parameters:
Returns:
Vector
a vector with pairs of EdgeId and bool values
Proposal
-
util.proposal.makeProposalData(proposal, context)
-
Tries to process a proposal and performs many checks including collisions, shapes and costs.
The result can be inspected to check for errors and other data.
Parameters:
Returns:
type.ProposalData
the generated proposal data
Terrain
-
terrain.getBaseHeightAt(position)
-
Fetches base height at the world position. Differently than terrain.getHeightAt, this does not include terrain alignments (non-permanent modifications)
and has a lower resolution of 4 meters. When the coordinates are outside the map, the value of the nearest position on the map is returned.
Parameters:
- position
type.Vec2f
world position with x and y coordinate from center of the map
Returns:
float
the height at the position
Usage:
api.engine.terrain.getBaseHeightAt(api.type.Vec2f.new(-123,42))
-
terrain.getHeightAt(position)
-
Fetches height at the world position. When the coordinates are outside the map, the value of the nearest position on the map is returned.
Parameters:
- position
type.Vec2f
world position with x and y coordinate from center of the map
Returns:
float
the height at the position
Usage:
api.engine.terrain.getHeightAt(api.type.Vec2f.new(-123,42))
-
terrain.isValidCoordinate(position)
-
Check if coordinate is within bounds of world.
Parameters:
- position
type.Vec2f
world position with x and y coordinate from center of the map
Returns:
boolean
true if valid coordinate, false if non valid coordinate
Usage:
api.engine.terrain.isValidCoordinate(api.type.Vec2f.new(-123,42))