modding:developerinfo:directorystructure

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

modding:developerinfo:directorystructure [2019/03/19 10:18] (current)
Line 1: Line 1:
 +====== Directory structure ======
 +
 +==== Important notice ====
 +
 +All text files (models, meshes, scripts etc.) should be encoded in UTF-8. Also, it is recommended to use lower-case file names to avoid problems on case-sensitive OSes / file systems.
 +
 +===== Mod layout =====
 +
 +The game’s installation folder (usually ''​C:​\Program Files (x86)\Steam\SteamApps\common\Transport Fever''​ on Windows) looks something like this:
 +<​code>​
 +Transport Fever\
 +  dlcs\
 +    ...
 +  mods\
 +    ...
 +  res\
 +    ...
 +  ...
 +</​code>​
 +
 +All mods must be installed in the ''​mods\''​ sub-directory. The directory structure is as follows:
 +<​code>​
 +Transport Fever\
 +  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)
 +</​code>​
 +
 +  - The directory name has the form ''<​id>​_<​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 version number is an integer starting at one.
 +  - Optionally contains mod-related config files (Lua files). These files can be “required” from other Lua files, i.e. the config directory is added to Lua’s package.path list.
 +  - Contains user documentation like manuals or read-me files. This directory is ignored by the game.
 +  - Most content (like models, textures etc.) goes into this directory. Everything in here can be thought of as if it had been copied (with overwrite) to the base ''​res/'' ​ folder.
 +  - The main file, contains metadata (like name, description etc.) and script code. See [[:​modding:​developerinfo:​scripting|Scripting]] for more information.
 +  - An image of 240×135 pixels, shown in the game.
 +  - Contains translations of the mod’s texts.
 +  - An image, shown in Steam workshop, when the mod is published.
 +  - Defines files and directories to be removed/​hidden from the base game.
 +
 +===== 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.
 +
 +===== mod.lua =====
 +
 +The basic structure of the file is as follows. See [[:​modding:​developerinfo:​scripting|Scripting]] for more information.
 +
 +<code lua>
 +function data()
 +return {
 +  info = {
 +    name = _("​Sample mod"​), ​        -- (1)
 +    description = _("​modDesc"​),​
 +    minorVersion = 0,               -- (2)
 +    severityAdd = "​WARNING", ​       -- (3)
 +    severityRemove = "​CRITICAL",​
 +  },
 +  -- options = ..
 +  -- runFn = ..
 +  -- checkActiveFn = ..
 +}
 +end
 +</​code>​
 +
 +  - Mod name and description. The ''​_("​text"​)''​ indicates that the text will be translated (see strings.lua below).
 +  - Minor version, count up from 0.
 +  - Defines what kind of warning to show when the mod is added to or removed from an existing savegame. Can be ''​NONE'',​ ''​WARNING'',​ or ''​CRITICAL''​.
 +
 +===== strings.lua =====
 +
 +<code lua>
 +function data()
 +return {
 +  en = {
 +    modDesc = "This is a sample mod.",
 +  },
 +  de = {
 +    ["​Sample mod"] = "​Beispiel-Mod",​
 +    modDesc = "Dies ist eine Beispiel-Mod.",​
 +  }
 +}
 +end
 +</​code>​
 +
 +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\''​.
 +
 +===== filesystem.lua =====
 +
 +<code lua>
 +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
 +</​code>​
 +
 +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).
 +
  
modding/developerinfo/directorystructure.txt · Last modified: 2019/03/19 10:18 (external edit)