Module game.interface

Transport Fever scripting interface functions.

Functions

getGameTime () Returns the current game time (and date).
getCargoTypes () Returns the list of cargo types.
getCargoType (id) Returns the specified cargo type.
getBuildingTypes () Returns the list of building types.
getBuildingType (id) Returns the specified building type.
getEntity (entity) Returns entity data.
getEntities (circle[, filter]) Returns a list of entities in a circle, optionally with entity data included.
getTowns () Returns the list of town entities.
getStations ([filter]) Returns a list of station entities.
getLines ([filter]) Returns a list of line entities.
getVehicles ([filter]) Returns a list of vehicle entities.
getDepots () Returns the list of depot entities.
getPlayer () Returns the player entity.
getPlayerJournal (from, to) Returns the player journal for the specified date range.
getWorld () Returns the world entity.
getHeight (pos) Returns the terrain height at the specified position.
findPath (from, to[, transportModes]) Searches a path between a station/circle and another station/circle.
getLog (entity, name, dates) Returns the log values for the specified dates.
setGameSpeed (speed) Sets the current game speed.
buildConstruction (fileName, param, transf) Builds a new construction.
upgradeConstruction (entity, fileName, param) Upgrades an existing construction.
bulldoze (entity) Bulldozes (removes) an entity.
clearJournal () Clears the player journal.
book (amount[, loan]) Adds a transaction to the player journal.
setName (entity, name) Sets an entity's name.
setBulldozeable (entity, bulldozeable) Sets whether an entity can be bulldozed or not.
replaceVehicle (entity, parts) Replaces the parts (model instances) of a vehicle.
addPlayer () Adds a player.
setPlayer (entity, playerEntity) Sets the player/owner of an entity.
startEvent (entity, index, name[, loop]) Start event/animation on specific model instance.
setBuildInPauseModeAllowed (allowed) Allow or prohibit to build while game is in pause mode.
setMarker (key[, marker]) Sets (adds/updates/removes) a marker.
setZone (key[, zone]) Sets (adds/updates/removes) a zone.


Functions

getGameTime ()
Returns the current game time (and date).

Returns:

    protocol.GameTime game time
getCargoTypes ()
Returns the list of cargo types.

Returns:

    {string,...} list of cargo types IDs
getCargoType (id)
Returns the specified cargo type.

Parameters:

Returns:

    protocol.CargoType cargo type
getBuildingTypes ()
Returns the list of building types.

Returns:

    {string,...} list of building types IDs
getBuildingType (id)
Returns the specified building type.

Parameters:

Returns:

    model.BuildingType building type
getEntity (entity)
Returns entity data.

Parameters:

  • entity int entity ID

Returns:

    table entity data
getEntities (circle[, filter])
Returns a list of entities in a circle, optionally with entity data included.

Parameters:

Returns:

    {int,...} or {[int]=table,...} list of entity IDs or map ID => data
getTowns ()
Returns the list of town entities.

Returns:

    {int,...} list of entity IDs
getStations ([filter])
Returns a list of station entities.

Parameters:

Returns:

    {int,...} list of entity IDs
getLines ([filter])
Returns a list of line entities.

Parameters:

Returns:

    {int,...} list of entity IDs
getVehicles ([filter])
Returns a list of vehicle entities.

Parameters:

Returns:

    {int,...} list of entity IDs
getDepots ()
Returns the list of depot entities.

Returns:

    {int,...} list of entity IDs
getPlayer ()
Returns the player entity.

Returns:

    int player entity id
getPlayerJournal (from, to)
Returns the player journal for the specified date range.

Parameters:

Returns:

    protocol.Journal journal data
getWorld ()
Returns the world entity.

Returns:

    int world entity id
getHeight (pos)
Returns the terrain height at the specified position.

Parameters:

  • pos vec2 position

Returns:

    number height
findPath (from, to[, transportModes])
Searches a path between a station/circle and another station/circle.

Parameters:

Returns:

    optional protocol.Path path data (if found)
getLog (entity, name, dates)
Returns the log values for the specified dates.

Parameters:

Returns:

    {int,...} list of values
setGameSpeed (speed)
Sets the current game speed.

Parameters:

  • speed int game speed (0: pause, 1: 1x, 2: 2x, 3: 4x)
buildConstruction (fileName, param, transf)
Builds a new construction.

Parameters:

  • fileName string construction file name
  • param table construction parameters
  • transf mat4 transformation matrix

Returns:

    optional int entity ID (on success)
upgradeConstruction (entity, fileName, param)
Upgrades an existing construction.

Parameters:

  • entity int entity ID
  • fileName string construction file name
  • param table construction parameters

Returns:

    optional int entity ID (on success)
bulldoze (entity)
Bulldozes (removes) an entity.

Parameters:

  • entity int entity ID
clearJournal ()
Clears the player journal.
book (amount[, loan])
Adds a transaction to the player journal.

Parameters:

  • amount number amount
  • loan bool if true, then booked as loan, else as other/income (optional)
setName (entity, name)
Sets an entity's name.

Parameters:

  • entity int entity ID
  • name string name
setBulldozeable (entity, bulldozeable)
Sets whether an entity can be bulldozed or not.

Parameters:

  • entity int entity ID
  • bulldozeable bool whether bulldozeable or not
replaceVehicle (entity, parts)
Replaces the parts (model instances) of a vehicle.

Parameters:

addPlayer ()
Adds a player.

Returns:

    int entity ID
setPlayer (entity, playerEntity)
Sets the player/owner of an entity.

Parameters:

  • entity int entity ID
  • playerEntity int player entity ID
startEvent (entity, index, name[, loop])
Start event/animation on specific model instance.

Parameters:

  • entity int entity ID
  • index int model instance index
  • name string event name
  • loop bool whether played in a loop or not (optional)
setBuildInPauseModeAllowed (allowed)
Allow or prohibit to build while game is in pause mode.

Parameters:

  • allowed bool whether allowed or not
setMarker (key[, marker])
Sets (adds/updates/removes) a marker.

Parameters:

setZone (key[, zone])
Sets (adds/updates/removes) a zone.

Parameters:

generated by LDoc 1.4.3 Last updated 2017-01-11 14:06:12