Module api.res

Repositories containing game resources (models, tracks, streets, ...)

Functions

getBaseConfig() A resource repository containing most of the data which was read from "res/config/base_config.lua".

Tables

autoGroundTexRep A resource repository containing data from the ".lua" files from "res/config/auto_ground_tex/" folder.
bridgeTypeRep A resource repository containing data from the bridge configuration files and from dynamically generated bridges.
buildingTypeRep A resource repository containing data for town buildings.
cargoTypeRep A resource repository containing data with all the cargo types.
constructionRep A resource repository containing data from the ".con" files and from dynamically generated constructions.
modelRep A resource repository containing all the game models and metadata.
moduleRep A resource repository containing data from the ".modules" files and from dynamically generated modules.
multipleUnitRep A resource repository containing data from the multiple unit files and from dynamically generated multiple units.
railroadCrossingTypeRep A resource repository containing data from the railroad crossing files and from dynamically generated railroad crossing types.
streetTypeRep A resource repository containing data from the street type files and from dynamically generated street types.
trackTypeRep A resource repository containing data from the track type files and from dynamically generated track types.
trafficLightTypeRep A resource repository containing data from the traffic lights.
tunnelTypeRep A resource repository containing data from the tunnel configuration files and from dynamically generated tunnels.

GenericRepositoryFunctions

repository.add(fileName, resource, visible) Adds a new resource into the repository.
repository.find(fileName) Find the repository index of the given resource.
repository.get(index) Obtains the resource with the given index.
repository.getAll() Fetches a list of all resources registered in the repository.
repository.getName(index) Returns the fileName (or identifier in case of dynamic resources) for the given index.


Functions

getBaseConfig()
A resource repository containing most of the data which was read from "res/config/base_config.lua".

Returns:

    Table the configuration table. See base config for a detailed explanation.

Tables

autoGroundTexRep
A resource repository containing data from the ".lua" files from "res/config/auto_ground_tex/" folder.
bridgeTypeRep
A resource repository containing data from the bridge configuration files and from dynamically generated bridges.
buildingTypeRep
A resource repository containing data for town buildings.
cargoTypeRep
A resource repository containing data with all the cargo types.
constructionRep
A resource repository containing data from the ".con" files and from dynamically generated constructions.
modelRep
A resource repository containing all the game models and metadata.
moduleRep
A resource repository containing data from the ".modules" files and from dynamically generated modules.
multipleUnitRep
A resource repository containing data from the multiple unit files and from dynamically generated multiple units.
railroadCrossingTypeRep
A resource repository containing data from the railroad crossing files and from dynamically generated railroad crossing types.
streetTypeRep
A resource repository containing data from the street type files and from dynamically generated street types.
trackTypeRep
A resource repository containing data from the track type files and from dynamically generated track types.
trafficLightTypeRep
A resource repository containing data from the traffic lights.
tunnelTypeRep
A resource repository containing data from the tunnel configuration files and from dynamically generated tunnels.

GenericRepositoryFunctions

repository.add(fileName, resource, visible)
Adds a new resource into the repository.

Notice that not all repositories have an add function, and that the add function is available only within the "postRunFn" function.

Additionally, all objects requiring a function need to be added with a script file instead. Additional state can be set in the script file. E.g.: a construction will have to use an "updateScript" instead of "updateFn" in order to add new resources. Additional state that will be passed to the construction will be placed in "updateScript.params". See the default postRunFn in the "base_mod.lua" as an example for generation of track type station modules.

Parameters:

  • fileName string a unique identifier for the resource, akin to a fileName for static resources
  • resource Resource the resource to add
  • visible bool the visibility (for GUI purposes) of the object
repository.find(fileName)
Find the repository index of the given resource. Might return -1 when no resource is found.

Parameters:

  • fileName string The fileName (or unique identifier in the case of dynamic resources).

Returns:

    int the index of the requested resource in the repository or -1

Usage:

    api.res.modelRep.find("bridge/suspension/pillar_main_top_rep.mdl")
repository.get(index)
Obtains the resource with the given index.

During postRunRn the resource obtained can be modified. However, during the game the result is just a copy of the data. Therefore modifications to the data won't have an effect.

Parameters:

  • index int the index of the resource to obtain

Returns:

    the requested resource

Usage:

    api.res.groundTextureRep.get(1)
repository.getAll()
Fetches a list of all resources registered in the repository.

Returns:

    Table A mapping from integer indices to fileNames (or identifier)

Usage:

    api.res.cargoTypeRep.getAll()
repository.getName(index)
Returns the fileName (or identifier in case of dynamic resources) for the given index.

Parameters:

  • index int the index of the resource

Returns:

    string the filename of the resource at the requested repository index

Usage:

    api.res.railroadCrossingTypeRep.getName(2)
generated by LDoc 1.4.3 Last updated 2023-04-18 15:10:38