Module api.res🔗
Repositories containing game resources (models, tracks, streets, ...)
global record Res
buildingTypeRep: ResTypeRep<integer, BuildingType> bridgeTypeRep: ResTypeRep<integer, BridgeType> constructionRep: ResTypeRep<integer, ConstructionDesc> metaConstructionRep: ResTypeRep<integer, MetaConstructionDesc> genericRep: GenericRep economyRep: ResTypeRep<integer, EconomyDesc> climateRep: ResTypeRep<integer, ClimateDesc> terrainGeneratorRep: ResTypeRep<integer, TerrainGeneratorDesc> environmentRep: ResTypeRep<integer, Environment> playlistRep: ResTypeRep<integer, PlaylistDesc> gameScriptRep: ResTypeRep<integer, GameScriptType> cargoClassRep: CargoClassRep cargoTypeRep: CargoTypeRep nameRep: ResTypeRep<integer, NameDesc> campaignRep: ResTypeRep<integer, CampaignDesc> missionRep: ResTypeRep<integer, MissionDesc> modelRep: ModelRep multipleUnitRep: ResTypeRep<integer, MultipleUnit> streetTemplateRep: ResTypeRep<integer, StreetTemplate> edgeDecorationRep: ResTypeRep<integer, EdgeDecoration> terrainMaterialTypeRep: ResTypeRep<integer, TerrainMaterialType> trafficLightTypeRep: ResTypeRep<integer, TrafficLightType> tunnelTypeRep: ResTypeRep<integer, BridgeType> moduleRep: ResTypeRep<integer, ModuleDesc> railroadCrossingTypeRep: ResTypeRep<integer, RailroadCrossingType> streetStyleRep: ResTypeRep<integer, StreetStyle> builderAudioSetRep: ResTypeRep<integer, BuilderAudioSet> soundSetRep: ResTypeRep<integer, SoundSet> groundTextureRep: ResTypeRep<string, GroundTexture> autoGroundTexRep: ResTypeRep<string, AutoGroundTex> getBaseConfig: function(): BaseConfig endglobal record CargoClassRep
getCargoClassId: function(cargoClass : string): CargoClassId hasCargoClass: function(cargoClass : string): boolean endglobal record CargoTypeRep
forEachCargoType: function(cargoTypeSet : CargoTypeSet, callback : function(CargoTypeId)) hasCargoType: function(cargoTypeSet : CargoTypeSet, test : CargoTypeId, inverse : boolean): boolean getPassengerCargoTypeId: function(): CargoTypeId endglobal record GenericRep
getAllOfType: function(typeName : string, includeInvisible : boolean): {integer} endglobal record ModelRep
forEachModelWithMetadata: function(metadata : string, callback : function(string)) endglobal interface ResTypeRep<K, T>
get: function(id : K): T getName: function(id : K): string find: function(resName : string): K findAndGet: function(resName : string): T getAll: function(includeInvisible : boolean): {K : string} add: function(resName : ResName, resource : T, visible : boolean): K setVisible: function(id : K, visible : boolean) isVisible: function(id : K): boolean getAsTable: function(id : K): T setAsTable: function(id : K, t : T): boolean addAsTable: function(the : ResName, t : T): K end
Category: main🔗
Res🔗
global record Res
buildingTypeRep: ResTypeRep<integer, BuildingType> bridgeTypeRep: ResTypeRep<integer, BridgeType> constructionRep: ResTypeRep<integer, ConstructionDesc> metaConstructionRep: ResTypeRep<integer, MetaConstructionDesc> genericRep: GenericRep economyRep: ResTypeRep<integer, EconomyDesc> climateRep: ResTypeRep<integer, ClimateDesc> terrainGeneratorRep: ResTypeRep<integer, TerrainGeneratorDesc> environmentRep: ResTypeRep<integer, Environment> playlistRep: ResTypeRep<integer, PlaylistDesc> gameScriptRep: ResTypeRep<integer, GameScriptType> cargoClassRep: CargoClassRep cargoTypeRep: CargoTypeRep nameRep: ResTypeRep<integer, NameDesc> campaignRep: ResTypeRep<integer, CampaignDesc> missionRep: ResTypeRep<integer, MissionDesc> modelRep: ModelRep multipleUnitRep: ResTypeRep<integer, MultipleUnit> streetTemplateRep: ResTypeRep<integer, StreetTemplate> edgeDecorationRep: ResTypeRep<integer, EdgeDecoration> terrainMaterialTypeRep: ResTypeRep<integer, TerrainMaterialType> trafficLightTypeRep: ResTypeRep<integer, TrafficLightType> tunnelTypeRep: ResTypeRep<integer, BridgeType> moduleRep: ResTypeRep<integer, ModuleDesc> railroadCrossingTypeRep: ResTypeRep<integer, RailroadCrossingType> streetStyleRep: ResTypeRep<integer, StreetStyle> builderAudioSetRep: ResTypeRep<integer, BuilderAudioSet> soundSetRep: ResTypeRep<integer, SoundSet> groundTextureRep: ResTypeRep<string, GroundTexture> autoGroundTexRep: ResTypeRep<string, AutoGroundTex> getBaseConfig: function(): BaseConfig end
List of all repositories
Res.buildingTypeRep🔗
Res.buildingTypeRep: ResTypeRep<integer, BuildingType>
A resource repository containing data for town buildings.
Res.bridgeTypeRep🔗
Res.bridgeTypeRep: ResTypeRep<integer, BridgeType>
A resource repository containing data from the bridge configuration files and from dynamically generated bridges.
Res.constructionRep🔗
Res.constructionRep: ResTypeRep<integer, ConstructionDesc>
A resource repository containing data from the ".con" files and from dynamically generated constructions.
Res.metaConstructionRep🔗
Res.metaConstructionRep: ResTypeRep<integer, MetaConstructionDesc>
A resource repository containing data for all custom resources.
Res.genericRep🔗
Res.genericRep: GenericRep
Res.economyRep🔗
Res.economyRep: ResTypeRep<integer, EconomyDesc>
A resource repository containing data from the ".eco" economy resources.
Res.climateRep🔗
Res.climateRep: ResTypeRep<integer, ClimateDesc>
A resource repository containing data for the climates.
Res.terrainGeneratorRep🔗
Res.terrainGeneratorRep: ResTypeRep<integer, TerrainGeneratorDesc>
A resource repository containing data for the terrain generation.
Res.environmentRep🔗
Res.environmentRep: ResTypeRep<integer, Environment>
A resource repository containing data for the environment.
Res.playlistRep🔗
Res.playlistRep: ResTypeRep<integer, PlaylistDesc>
A repository for playlists.
Res.gameScriptRep🔗
Res.gameScriptRep: ResTypeRep<integer, GameScriptType>
A resource repository containing game scripts.
Res.cargoClassRep🔗
Res.cargoClassRep: CargoClassRep
A resource repository containing data with all the cargo classes.
Res.cargoTypeRep🔗
Res.cargoTypeRep: CargoTypeRep
A resource repository containing data with all the cargo types.
Res.nameRep🔗
Res.nameRep: ResTypeRep<integer, NameDesc>
A resource repository for names.
Res.campaignRep🔗
Res.campaignRep: ResTypeRep<integer, CampaignDesc>
A resource repository for campaign chapters.
Res.missionRep🔗
Res.missionRep: ResTypeRep<integer, MissionDesc>
A resource repository for campaign missions.
Res.modelRep🔗
Res.modelRep: ModelRep
A resource repository containing all the game models and metadata.
Res.multipleUnitRep🔗
Res.multipleUnitRep: ResTypeRep<integer, MultipleUnit>
A resource repository containing data from the multiple unit files and from dynamically generated multiple units.
Res.streetTemplateRep🔗
Res.streetTemplateRep: ResTypeRep<integer, StreetTemplate>
A resource repository containing data from the street template files and from dynamically generated street templates.
Res.edgeDecorationRep🔗
Res.edgeDecorationRep: ResTypeRep<integer, EdgeDecoration>
Res.terrainMaterialTypeRep🔗
Res.terrainMaterialTypeRep: ResTypeRep<integer, TerrainMaterialType>
A resource repository containing materials.
Res.trafficLightTypeRep🔗
Res.trafficLightTypeRep: ResTypeRep<integer, TrafficLightType>
A resource repository containing data from the traffic lights.
Res.tunnelTypeRep🔗
Res.tunnelTypeRep: ResTypeRep<integer, BridgeType>
A resource repository containing data from the tunnel configuration files and from dynamically generated tunnels.
Res.moduleRep🔗
Res.moduleRep: ResTypeRep<integer, ModuleDesc>
A resource repository containing data from the ".modules" files and from dynamically generated modules.
Res.railroadCrossingTypeRep🔗
Res.railroadCrossingTypeRep: ResTypeRep<integer, RailroadCrossingType>
A resource repository containing data from the railroad crossing files and from dynamically generated railroad crossing types.
Res.streetStyleRep🔗
Res.streetStyleRep: ResTypeRep<integer, StreetStyle>
A resource repository containing data from the street type files and from dynamically generated street types.
Res.builderAudioSetRep🔗
Res.builderAudioSetRep: ResTypeRep<integer, BuilderAudioSet>
A resource repository containing data for audio sets for building
Res.soundSetRep🔗
Res.soundSetRep: ResTypeRep<integer, SoundSet>
A resource repository containing data for sound sets
Res.groundTextureRep🔗
Res.groundTextureRep: ResTypeRep<string, GroundTexture>
A resource repository containing data for ground textures.
Res.autoGroundTexRep🔗
Res.autoGroundTexRep: ResTypeRep<string, AutoGroundTex>
A resource repository containing data for automatic ground texture definitions.
Res.getBaseConfig🔗
function Res.getBaseConfig(): BaseConfig
Gets the base config, it contains most of the data which was read from "base/base_config.lua".
ReturnsBaseConfig— Table the configuration table. See https://wiki.transportfever3.com/doku.php?id=modding:baseconfig for a detailed explanation.
Category: globals🔗
CargoClassRep🔗
global record CargoClassRep
getCargoClassId: function(cargoClass : string): CargoClassId hasCargoClass: function(cargoClass : string): boolean end
CargoClassRep.getCargoClassId🔗
function CargoClassRep.getCargoClassId(cargoClass : string): CargoClassId
Gets the CargoClassId for a given CargoClass name
ParameterscargoClass:string— cargo class name
CargoClassId— cargo class id
CargoClassRep.hasCargoClass🔗
function CargoClassRep.hasCargoClass(cargoClass : string): boolean
Checks if the given cargo class is present, this can be used if some cargo classes exist but are invisible
ParameterscargoClass:string— cargo class name
boolean— true if present
CargoTypeRep🔗
global record CargoTypeRep
forEachCargoType: function(cargoTypeSet : CargoTypeSet, callback : function(CargoTypeId)) hasCargoType: function(cargoTypeSet : CargoTypeSet, test : CargoTypeId, inverse : boolean): boolean getPassengerCargoTypeId: function(): CargoTypeId end
CargoTypeRep.forEachCargoType🔗
function CargoTypeRep.forEachCargoType(cargoTypeSet : CargoTypeSet, callback : function(CargoTypeId))
Iterates over all cargo types in a given cargo type set
ParameterscargoTypeSet:CargoTypeSet— the cargo type set to iterate overcallback:function(CargoTypeId)— a callback for each cargo type
CargoTypeRep.hasCargoType🔗
function CargoTypeRep.hasCargoType(cargoTypeSet : CargoTypeSet, test : CargoTypeId, inverse : boolean): boolean
Checks if a cargo type set contains a specific cargo type
ParameterscargoTypeSet:CargoTypeSet— the cargo type set to checktest:CargoTypeId— the cargo type to test forinverse:boolean— if true, the function returns true when any other cargo exists
boolean
CargoTypeRep.getPassengerCargoTypeId🔗
function CargoTypeRep.getPassengerCargoTypeId(): CargoTypeId
Returns the cargo type id for passenger
ReturnsCargoTypeId
GameScriptType🔗
GameScriptType.getState🔗
function GameScriptType.getState(GameScriptType): {<any type> : <any type>}Parameters
GameScriptType
{<any type> : <any type>}
GenericRep🔗
global record GenericRep
getAllOfType: function(typeName : string, includeInvisible : boolean): {integer} end
GenericRep.getAllOfType🔗
function GenericRep.getAllOfType(typeName : string, includeInvisible : boolean): {integer}
Gets all Generic resource types of a given type name
does not allow typeName in { "guiresoverwrite", "gui_res" }, for those, use api.gui.genericRep
typeName:string— type nameincludeInvisible:boolean— whether to include invisible
{integer}— resource ids
ModelRep🔗
global record ModelRep
forEachModelWithMetadata: function(metadata : string, callback : function(string)) end
ModelRep.forEachModelWithMetadata🔗
function ModelRep.forEachModelWithMetadata(metadata : string, callback : function(string))
Iterates over all the models with a specific metadata
Parametersmetadata:string— the name of the metadatacallback:function(string)— a callback for every model that contains the specified metadata
ResTypeRep🔗
global interface ResTypeRep<K, T>
get: function(id : K): T getName: function(id : K): string find: function(resName : string): K findAndGet: function(resName : string): T getAll: function(includeInvisible : boolean): {K : string} add: function(resName : ResName, resource : T, visible : boolean): K setVisible: function(id : K, visible : boolean) isVisible: function(id : K): boolean getAsTable: function(id : K): T setAsTable: function(id : K, t : T): boolean addAsTable: function(the : ResName, t : T): K end
Generic interface for repositories
Resources are generally static (initialized when the game starts and don't change)
Make sure that resource exists before trying to access them
Resource ids are only valid within the same repository
Type Parameters
KT
ResTypeRep.get🔗
function ResTypeRep.get(id : K): T
Gets the resource for a given id - (can be used to directly modify the resource,
but this is discouraged, except for performance reasons. Use getAsTable and setAsTable instead.
id:K— a resource id
T— the resource
ResTypeRep.getName🔗
function ResTypeRep.getName(id : K): string
Gets the resource name for a given id
Parametersid:K— a resource id
string— the resource name
ResTypeRep.find🔗
function ResTypeRep.find(resName : string): K
Finds the id of the given resource name and returns its id
ParametersresName:string— a resource name
K— the id of the resource, -1 if the resource doesn't exist
ResTypeRep.findAndGet🔗
function ResTypeRep.findAndGet(resName : string): T
Finds the resource with the given name and returns it
ParametersresName:string— a resource name
T— the resource, and an error if the resource is not found
ResTypeRep.getAll🔗
function ResTypeRep.getAll(includeInvisible : boolean): {K : string}
Gets all resources
ParametersincludeInvisible:boolean— if invisible resources should be included, false by default
{K : string}— a dictionary containing all id and resource names
ResTypeRep.add🔗
function ResTypeRep.add(resName : ResName, resource : T, visible : boolean): K
Adds a new resource to the repository
ParametersresName:ResName— the resource name of the new resourceresource:T— the resource itselfvisible:boolean— if the resource is visible
K— the id of the newly added resource
ResTypeRep.setVisible🔗
function ResTypeRep.setVisible(id : K, visible : boolean)
Sets a resource visible
Parametersid:K— the id of the resourcevisible:boolean— if the resource should be visible
ResTypeRep.isVisible🔗
function ResTypeRep.isVisible(id : K): boolean
Checks if a resource is visible
Parametersid:K— the id of the resource
boolean— if the resource is visible
ResTypeRep.getAsTable🔗
function ResTypeRep.getAsTable(id : K): T
Gets the resource for a given id as a pure lua table
Parametersid:K— a resource id
T— the resource
ResTypeRep.setAsTable🔗
function ResTypeRep.setAsTable(id : K, t : T): boolean
Updates the resource for a given id from a pure lua table (as if it was the resource file)
Parametersid:K— a resource idt:T— the resource
boolean— success
ResTypeRep.addAsTable🔗
function ResTypeRep.addAsTable(the : ResName, t : T): K
Add a new resource from a pure lua table (as if it was the resource file)
Parametersthe:ResName— name of the resource to add (should be unique)t:T— the resource to add
K— the newly added id