Mods are folders with a specific file hierarchy:
mods/ urbangames_sample_mod_1 (1) config/ (2) (optional) ... documents/ (3) (optional) ... res/ (4) (optional) ... mod.lua (5) image_00.tga (6) (optional) strings.lua (7) (optional) workshop_preview.jpg (8) (optional) filesystem.lua (9) (optional)
<id>_<major_version>
. The ID should be as specific as possible, so it should definitely contain the author’s name (or organization) and the mod name. The major version number is an integer starting at one.res/
folder.
Major Versions
Different versions of the same mod are independent of each other, but when starting a new game, only the latest version is shown to the user.
The basic structure of the file is as follows.
function data() return { info = { name = _("Sample mod"), description = _("modDesc"), authors = { { name = "Urban Games", role = 'CREATOR', }, }, minorVersion = 0, severityAdd = "WARNING", severityRemove = "CRITICAL", params = { ... }, url = "https://...", }, -- runFn = function (settings, modParams) ... -- postRunFn = function (settings, params) ... } end
The info
block contains the basic informations about mods:
name
is the mod name that is visible in mod lists and mod details.description
is the mod description that is visible in the mod details section.authors
is a block containing the authors of the mod and their roles.minorVersion
is the minor version. It is shown behind the mod name in lists and details when greater than 0.severityAdd
defines what kind of warning to show when the mod is added to an existing savegame. Can be NONE
, WARNING
, or CRITICAL
.severityRemove
defines what kind of warning to show when the mod is removed from an existing savegame. Can be NONE
, WARNING
, or CRITICAL
.params
is a block with custom mod parameters analogue to construction parameters. They can be used in runFn
by calling modParams[getCurrentModId()]
.url
is a link to a website where the mod can be found for manual download. It is necessary to include the “https” prefix.
The _(“text”)
indicates that the text will be translated (see strings.lua below).
See the scripting basics to find out more about the script functions that can be provided in the mod.lua
.
A small demo mod was provided in the game release notes once the mod parameter feature was introduced. You can download it here too.
function data() return { en = { modDesc = "This is a sample mod.", }, de = { ["Sample mod"] = "Beispiel-Mod", modDesc = "Dies ist eine Beispiel-Mod.", } } end
This file contains translations for strings, specified as a list of key/value pairs for each language. If a key does not exist for a given language, the English text is used. If this isn’t defined neither, the key itself is displayed. For a list of possible language codes, see the directory res/strings/
and have a look at the information on localization.
function data() return { hiddenDirs = { "res/models/model/vehicle/truck/" }, hiddenFiles = { "res/models/model/vehicle/train/borsig_1860.mdl", "res/models/model/vehicle/train/br75_4.mdl" } } end
Allows to specify files and directories that are to be hidden from the game, i.e. it has the same effect as deleting the file(s).
A soft way of filtering resources is to use a file filter.
The directory structure in mods is similar to the one from the Transport Fever 2 game resources. Below is a description of all relevant folders located below the res
-folder. Only those which are relevant for a specific mod need to be included in a mod.
If additional resources should be added by a mod, the file names should not match existing file names. If existing resources (from game or other mods) should be overriden by a mod, the directory structure and file names have to be exactly replicated. The load order of mods depends, which files are used. The last one overrides the others.
Thus it is recommended not to override existing files whenever it is possible to preserve compatibility to other mods!
audio
music
: music tracks for the background musiccampaign
: the savegames used for starting the missions of the campaigns and the config for bonus medals in missionsconfig
: the base config files used by the gameauto_ground_tex
: configurations of ground textures applied around landscape assets (trees and rocks)bridge
: configurations of rail and road bridges cargo_types
: configurations of cargo typesclimate
: configurations of climatesconstruction_sound
: configuration of sound effectsenvironment
: configurations of environmentsgame_script
: game script files used by mission scripts (and mods)grass
: configurations of grass and other small plants visible on some terrain materialsground_texture
: configurations of ground textures, e.g. around constructionsmultiple_unit
: configurations of multiple unitsname2
: lists of people, street and town namesrailroad_crossing
: configurations of railroad crossingssound_set
: configurations of sound setsstreet
: configurations of streets style_sheet
: configurations of various user interface elementsterrain_generators
: configuration scripts of the terrain generation and asset distribution, e.g. foreststerrain_heightmaps
: heightmap templates for brush tool terrain_materials
: configurations of terrain materials used by terrain generation as well as brush toolstrack
: configurations of trackstraffic_light
: configurations of traffic lights tunnel
: configurations of rail and road tunnels ui
: configurations of common categories in construction menusconstruction
: asset
: asset constructions for mainly decorative elementsbuilding
: building constructions for town buildings built by the gamedepot
: constructions for street, tram or rail depotsindustry
: constructions for industriesplaceholders
: placeholder constructions for the fallback mechanismstation
: station constructions for all types of transportstreet
: street constructions e.g. roundaboutswaterway
: water constructions e.g. buoysfonts
: font types used by the gamemodels
: all 3D resource files like models, meshes, materials and animations.scripts
: generic scripts used in various placesmission
: script files used by missionsmodules
: script files used by modular constructionsterrain
: script files for the terrain generation and asset distribution, e.g. forestsshaders2
: script files for the shaders used by the game enginestrings
: texts for the languages supported by the base game (see localizations for information about custom translations of game texts)textures
: default neutral texturesenvironment
: textures used by the environment, e.g. the skyboxground_texture
: textures used for ground textures, e.g. around constructionsmodels
: textures used for most of the 3D models, e.g. vehicles, buildings and assetsstreets
: textures used for streetstracks
: textures used for rails and sleepers of trackstrees
: textures used by treesui
: icons and preview images for the user interface and menus as well as construction parameter image buttons