Transport Fever

Transport Fever

51 ratings
Modding Transport Fever - Basic Overview, Resources, Tips
By JK
This is a limited guide, resource listing and some tips on modding Transport Fever. It is not a full guide on all aspects nor an absolute beginners guide, but should provide enough information for the semi-initiated to move themselves forward. It is mainly written with trains in mind, but a lot of it is applicable to all vehicles and some of it to other mod types too.
 
Rate  
Favorite
Favorited
Unfavorite
Prerequisites and Basic Concepts
First read the Official information on modding (at the time of writing it is limited, hence this guide), as I have not bothered to duplicate it:
Transport Fever Wiki - Mod Development : http://transportfever.com/wiki/doku.php?id=modding:developerinfo:start

Sofware required:
3D modelling software - Blender is free (most other 3D programs can be used to make the models, but for the method detailed below, you'll then need to use Blender and a plugin to get them into the format for the game.) https://www.blender.org/download/
Image editing software with layers and full save options for .tga format (for the method below) - GIMP is free. https://www.gimp.org/downloads/
Text editing software - Notepad++ is free (you can get away with Window's Notepad but it will be a pain). https://notepad-plus-plus.org/download/

Software that is useful: File manager software that can do wildcard renames etc

You won't need to write any script from scratch, only copy and edit existing code as the most complex bit get done by the Blender export plugin. The configuration files are in plain text format (but extensions won't be recognised so use open or associate them with you text editor). If you use the game developers Model Viewer tool it does a reason job of telling you where your mistakes are in the code. A background in these subjects (3D modelling, image editing, coding, fault-finding or similar) and a lot of patience will aid you greatly. A Google search and Youtube tutorials will answer all manner of questions on Blender and texturing. A lot can be learnt by looking at the stock/vanilla files (they are in the same format as mods) or other be people's mods from the Workshop.

File and Folder naming:
Unique filenames should be used to prevent conflicts with your own or others' mods. (e.g. prefix them the mod name and maybe your username)
lower case is recommended (since Linux and Mac operating systems can have case sensitive file systems, which can cause issues)
Underscores or hyphens are recommended instead of spaces.

Correct folder directory naming and structure is very important for the game.

Folder path parameters in the files use forward slashes " / " instead of back slashes " \ ". (So will need correction if copying and pasting from Windows file explorer!.)
Folder path are relative (no C:\ drive letter etc) and combines with the expected folder systems of the game.
e.g. a texture specified in a .mtl file is "models/vehicle/train/my_mod_texture.tga" and the game expects textures will be located within "[ MOD FOLDER ] /res/textures/", so adds this on itself when it loads it.

Coordinate system:
X Along the direction of the track, forwards (positive) and back (negative).
Y Sideways, Left (positive) and Right (negative), the centre of the track is 0.
Z Height, up (positive), the top of the rails is 0.

For scaling values -1 can be used mirror or reverse a mesh, but it applies to textures too! (So any writing in the image will be backwards, unless compensated for.)
3D Modelling with Blender & Exporting
Before getting too deep into the 3D modelling, think about the limitations and requirements for the game; the model can't be too detailed and some parts must be separate objects. The model will need to be scaled to the rails. You can assume these to be 1.5m apart, so one at Y: +0.75 and one at Y: -0.75 (with 1 Blender unit acting as 1m). It is best to save several versions as you go along, especially when triangulating the model for export.

Level Of Detail (LOD)
Some guidelines based on the vanilla/stock models:
LOD 0: 10,000 faces, for 0-150 distance
LOD 1: 1,000 faces, for 150-300 distance
LOD 2: 100 faces, for 300-2000 distance

You might get away with more (up to double) but can affect performance, especially if there will be many instances of your item (e.g. carriages). (Won't somebody please think of the low spec'd PCs!)

Blender Import/Export Plugin
The below plugin for Blender is used to get the 3D model from Blender into the game's format and also does a lot of the work of creating the configuration files.

2017 version:
https://www.transportfever.net/index.php/Thread/7876-Blender-Import-Export-Addon-aktuell-Version-0-5-3-Alphatest/?postID=169526#post169526

2015 version:
https://www.transportfever.net/filebase/index.php/Entry/2-Blender-Import-Export-Addon/
https://www.transportfever.net/lexikon/index.php/Entry/201-Blender-Import-Export-Add-on/

Before exporting:
  • Name the objects and textures to save lots of (and maybe repeated) renaming later. Names from textures and vertices (grey upsidedown triangle icon) are used by the plugin when the files and config files are written. The same goes for material names. (When working in Blender, for objects; use Duplicate instead of Copy+Paste to prevent materials getting repeated as .000, .001, etc).
  • 'empty' entities became .mdl files and their 'children' (sub entities) get listed within their config files. i.e. when you select and export the 'empty' all it's children get exported at the same time (empties within empties don't work). Objects or collections of objects that pivot separately as the train corners (e.g. bogie assembly, engines and tenders) should each have their own 'empty' (which are exported separately).
  • UV map - All meshes must have a UV map for textures. If you haven't made a proper one, you can make one for a solid coloured object by going to Object Data tab (grey upsidedown triangle icon), UV Maps, 'plus' button to add a new one.
  • Material - All meshes must have a material (but it can be blank). (It seems the plugin should be able to create the .mtl file too, but I haven't managed it, so this might be a Blender version conflict or maybe it requires a specific method for texturing in Blender.)
  • Reset scale and rotation (CTRL+A, select) (If you don't reset scale, the scale values will go into the config files and normally work, but will be harder if scaling in the files is later needed.).
  • Tab, select none (A) before exporting (so it will select only faces with ngons)

Plugin Export Settings
From File, Export, Train Fever ...
Check the filename and "Mesh dir" (these are normally the same).
Check "Model type".
For .mdl files (from 'empties') normally tick these:
  • unselected faces
  • Select Ngons
  • Override files (overwrites existing files of the same name!)
  • Sub files
  • Directory structure
  • Bounding Box
Errors:
In addition to the popup errors that disappear, there is log in Blender that can be accessed by dragging down the top menu bar.
  • 'ngons' (select the object, edit and triangulate (Tab, CTRL+T)) - 'ngons' are faces that have too many vertices for the game format, i.e. not rectangular or triangular.
  • UV map missing - you forgot to add any UV map (see above)
  • UI scene error - RuntimeError: Error: Scene 'UI_small' - This is now normal and seems to be a conflict between the plugin and latest version of Blender. Extra blank scenes get create and can be deleted (sometimes selecting or deleting these scenes causes a crash, save first).
Configuration Files & Mesh Configuration
Files:

.msh - The Mesh file contains the material path for .mtl file (plus other data that shouldn't normally be changed), e.g. "vehicle/train/my_mod-body.mtl"
.msh.blob - The Mesh Blob file is the actual 3D mesh. This is not a text file and should never normally be directly edited.
The .msh and .msh.blob are pair of linked files and must always have the same filename (before the first '.').

.mtl - The Material file has details of the texture image files and their configuration. (A single Material file can be used by multiple Meshes.)

.mdl - The Model file is the master file which has details of all Meshes (or Group) files. Meshes are specified here (by the plugin with default setting) with their scale and coordinates. Also includes all the parameters of mod in the game, e.g. bounding box, speed etc, smoke effects, sounds, etc (but most are not created by the plugin, so will need copying from elsewhere).

.grp - The Group file can do some of Model file's function in specifying Meshes. This can be helpful for keeping the Model file shorter, when using multiple LODs (each Level of Detail can have it's own Group file), when using bogies or an engines with tender (so they pivot on the track separately, see below).

When editing, white space (tab and space characters) isn't important, but is useful for human readability. Commas, brackets and quotation marks are important and will create errors if missed or in the wrong place. Quotation marks ( " ) can't be used within text descriptions of mods, use single quote ( ' ) instead. Comments (lines ignored by the game) must be proceeded by "--", e.g. "-- I can write what I like on this line without creating an error"

For specifying Meshes:
{ id = "vehicle/train/my_mod_123/my_mod_123_body.msh", transf = { 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.386, 0.0, 2.24, 1.0, }, type = "MESH", },

The important numeric values in "transf" are:
transf = { [X Scale], 0.0, 0.0, 0.0, 0.0, [Y Scale], 0.0, 0.0, 0.0, 0.0, [Z Scale], 0.0, [X Position], [Y Position], [Z Position], 1.0, },

For specifying Groups:
{ id = "vehicle/train/my_mod_123_body.grp", transf = { 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, }, type = "GROUP", },

Normally the last number should always be 1 (or 1.0), since this means items will inherit values from their parents (e.g changing the position of a Group will also move all Meshes within it).

A crude method for rotating objects in the files (rather than before hand in Blender), is to use the transformation values, which can be calculated with this tool:
Transformation Calculator for Train Fever : http://ftp.train-fever.net/transformation/

LODs
Low fidelity versions of the model should be used when zoomed help with performance (see guidelines above). This is normally done by having 3D models with less detail (less faces and vertices). Alternatively, if you are using additional meshes for detail or small parts, you can leave them out at further distances, which also reduces the face count. The for this is:
visibleFrom = 0, visibleTo = 150,
So the next LOD in this example starts from 150 (if there is a gap the model will disappear). Bear in mind the Model Viewer can only zoom out to about 800 when testing this. Shadows and passengers disappear automatically at preset distances.
Take care when duplicating these blocks of code to create the LODs, to select the right portion of code, each LOD section will have these parts:
{ children = { -- Meshes or Groups here }, events = { -- Optional, animation event here }, matConfigs = { -- lots of zeros here }, static = false, visibleFrom = 0, visibleTo = 180, },

Bounding Box
"boundingInfo" has bbMax (positive) and bbMax (negative) values telling the game how far the whole 3D model extends in all directions. If not correct other vehicles will intercet with it or leave a big gap between them. It is also used when the Model Viewer creates the UI icons (part of the image will be chopped off if this is set too small). Once you have the approximate values you wish to adjust it by trial and error by testing in-game, with a wagon in front and behind it, and check it on the corners (the buffers can intersect messily if too close). The bounding box is also used to determine when the game renders the item on screen, if it's not right then things suddenly vanish when the objects would still be on screen.

Wheels / Axles
Specify "axles", as the Meshes that are the wheels. These will be used to position wheels (and all other parts based upon the wheels) as the train goes round curves. They will also be rotated/turned automatically as the train moves forward (so don't need any animation). This mesh can be a complete axle with wheels on each end (as one object) or individual wheels that are mirrored (scale -1) on one side. The same mesh only needs specifying once as an axle, even if it is used multiple times. You will need to specifiy axles for each LOD the wheel meshes are in.

configs = { { axles = { "vehicle/train/my_mod_123/my_mod_123_wheel_bogie.msh" "vehicle/train/my_mod_123/my_mod_123_wheel.msh" }, }, { axles = { "vehicle/train/my_mod_123/my_mod_123_wheel_bogie_low-res.msh" "vehicle/train/my_mod_123/my_mod_123_wheel_low-res.msh" }, }, { axles = { "vehicle/train/my_mod_123/my_mod_123_wheel_bogie_low-res.msh" "vehicle/train/my_mod_123/my_mod_123_wheel_low-res.msh" }, }, },
(See the Vehicle Specification section of the guide for where to position this code.)

Bogies and Pivoting Parts

Hierarchy for a waggon or carriage with bogies at each end:
    Model
  • Body Group
  • Bogie Group
  • Bogie Group (the same Group again with a different position in the configuration)
(the origin (zero) of the body and bogie groups should be in their respective centres)

Hierarchy for steam engine with front bogie and tender:
    Model
  • Body Group
  • Tender Group
(the origin (zero) of the body and bogie groups should be in their respective centres)

Hierarchy for a steam engine with front bogie and tender:
    Model
  • Body Group*
    • Bogie Group
  • Tender Group
(*main body mesh has its origin (zero) offset at the centre of the driving wheels, not the centre of the body)

For further methods research 'fake bogies'...
Texturing
Image Formats:
.tga format (use Export in GIMP)
  • Origin: Bottom Left (otherwise it will be reversed)
  • No RLE Compression
  • Transparency layer can be removed to reduce file size (if not needed)
.dds format can also be used (nearly all the vanilla/stock models use it) but is more complex and not cover in this guide.

Also see this guide which has some applicable information, covers .dds format and will be very useful if you have this paid software :
http://steamcommunity.com/sharedfiles/filedetails/?id=777161863

Texture sizes (dimensions) are most performance efficient if they are square and in binary/'power of 2' values, e.g 512x512px, 1024x1024px, 2048x2048px, 4096x4096px.
In .tga format the larger dimensions give much large file sizes, the above values give 1MB, 4MB, 16MB, 64MB. (Steam will zip/compress files when you upload them, and people download them, but they still take up lots of disk space, for you and the subscribers.)
The stock/vanilla models have textures up to 4096x4096px, but are in are .dds format which is always compressed so has much smaller filesizes.
A good starting point is 1024x1024px, or 2048x2048px if you want a lot of detail.
If using textures as a single block of colour (e.g. for a simple MGA map) they can be smaller, e.g. 128x128px.

The textures use separate image files that combine to create the visual appearance of the 3D object in the game. Some of the texture 'maps' use the 3 colour channels (Red, Green, Blue) of an RGB image to contain information for 3 different uses (so are like 3 images in one file).

Types:
  • Image Texture ('Albedo') - The actual colour image that is the object. (May also include transparency, aka 'alpha'.)
  • MGA Map (Metal, Gloss, Ambient Occlusion) - How light reacts with the object and the Image Texture.
    • Red channel is Metal effect (how much shine spreads over an area, higher values mean more concentrated). Try starting at 64 and experiment.
    • Green channel is Gloss effect (how much shine effect there is, higher values mean brighter/more shine). Try starting at 64 and experiment.
    • Blue channel is Ambient Occlusion (lighting, to vary the brightness of areas, higher values mean brighter). A reasonable starting value is 192.
  • 'Normal' (aka Bump, Environment) Map - Used to create 3D looking detail affects without increasing the real 3D meshes detail. It uses lighting effects to make a flat surface appear raised or lowered to give the illusion of 3D detail. Red, Green and Blue channels affect this, the base level should be 128,128, 255. For further info research bump/normal texture maps.
  • Cblend (Colour Blend) (only) Map - Used for custom colours and affects how the custom colour mixes with the Image Texture. Black (0,0,0) means the full custom colour is applied, White (255,255,255) means no custom colour is applied, values in between apply a mixture. This is used in conjunction with a value in the .mtl file.
  • CDR Map (Colour Blend, Dirt, Rust) - Colour Blend is as above in the Red channel. Dirt is the Green channel and Rust is the Blue channel, and work similarly to Colour Blend (the darkest areas are most affected) and in conjunction with extra values in .mtl file.

A basic example of a .mtl file, with just Image Texture (without transparency) and MGA Map:
function data() return { params = { fade_out_range = { fadeOutEndDist = 20000, fadeOutStartDist = 10000, }, map_albedo = { compressionAllowed = true, fileName = "models/vehicle/train/FILENAME.TGA", magFilter = "LINEAR", minFilter = "LINEAR_MIPMAP_LINEAR", mipmapAlphaScale = 0, type = "TWOD", wrapS = "CLAMP_TO_EDGE", wrapT = "CLAMP_TO_EDGE", }, map_metal_gloss_ao = { compressionAllowed = true, fileName = "models/vehicle/train/FILENAME_MGA.TGA", magFilter = "LINEAR", minFilter = "LINEAR_MIPMAP_LINEAR", mipmapAlphaScale = 0, type = "TWOD", wrapS = "CLAMP_TO_EDGE", wrapT = "CLAMP_TO_EDGE", }, polygon_offset = { factor = 0, units = 0, }, two_sided = { flipNormal = false, twoSided = false, }, }, type = "PHYSICAL", } end

In GIMP, to view and edit the 3 colour channels separately, go on the Windows menu, Dockable Dialogs, Channels.

Material (.mtl) file:
This image table shows the possible types and parameters. "PHYSICAL_NRML_MAP" is a good starting point to cover the basics and if you aren't using transparency (or use "PHYSICAL_NRML_MAP_CBLEND" if you want custom colours).
https://www.transportfever.net/index.php/Attachment/69526-Materialien-png/
It come from this page on the subject written in German (Google translate version):
https://translate.google.co.uk/translate?hl=en&sl=de&u=https://www.transportfever.net/lexikon/index.php/Entry/174-Materialien-mtl-s/

In-game compression can be used with "compressionAllowed = true,". It is probably better to use this whenever possible, since disabling this could reduce performance (especially with large textures). However, this in-game compression may remove subtle detail from textures and may cause banding in smooth gradients with .tga images. It can also create issues with bump maps.

Custom colours:
This needs a material type etc with "map_cblend".
Needs this line after "params = {", where "2.5" is a variable that should be played with to get the best looking result for all custom colours (this is tricky when the original texture is dark).
color_blend = { albedoScale = math.pow(1.37, 2.5), }
Vehicle Specification
Example:
metadata = { description = { name = "My Mod 123", description = "Something vaguely interesting about My Mod 123...", }, railVehicle = { topSpeed = 100, weight = 100, engines = { { type = "STEAM", power = 1000, tractiveEffort = 100, }, }, configs = { { axles = { "vehicle/train/my_mod_123/my_mod_123_wheel.msh", }, }, }, soundSet = { name = "train_steam_modern" } availability = { yearFrom = 1900, yearTo = 1950, }, cost = { price = -1, }, maintenance = { lifespan = 40, runningCosts = -1, }, },

"yearTo" can be 0 for no end year.
"price" and "runningCosts" will be automatically calculated by the game if a value of -1 is set.
("engines")"type" is either "STEAM", "DIESEL" or "ELECTRIC"
"power" in kW. "tractiveEffort" in KN. "topSpeed" in kph (km/h). "weight" in tonnes (t)
The order of the parameters doesn't matter (provided they're within the right parent parameter).
Cargo, Passenger & Drivers
Cargo & Passengers Capacities:
Capacity (this value is the capacity divided by 4 (below will be 6 goods):
{ type = "GOODS", capacity = 24 }

Typical types and the load variable names:
Open Waggon: COAL IRON_ORE STONE GRAIN SLAG
Flat Waggon: LOGS STEEL PLANKS CONSTRUCTION_MATERIALS
Tank Waggon: CRUDE OIL FUEL
Closed Van: LIVESTOCK PLASTIC MACHINES TOOLS FOOD GOODS
Carriage: PASSENGERS

For visible freight cargo loading animation and fill levels there are two method: 'Discrete' to show objects (e.g. crates or logs) and 'Level' intended for loose material in a hopper or open waggon (stone, coal, iron ore, slag).
'Discrete' lets you specify the id's of meshes to show. When there are mulitple meshes it represents fill level (e.g. 100% load shows all meshes, 50% load shows the first half of them, etc).
'Level' raises the specified mesh from it's current height, by adding on a value, up to maxHeight for 100% load.
Example code of the two types:
{ type = "CONSTRUCTION_MATERIALS", capacity = 24, loadIndicators = { { type = "DISCRETE", params = { items = { 4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19 } } } } }, { type = "STONE", capacity = 24, loadIndicator = { type = "LEVEL", params = { id = 2, maxHeight = 0.8 } } },

If you need to know to what object numbers you have (e.g. for cargo load animation configuration), this tool can help:
TF ID Counter - This tool counts all IDs that belong to a certain children.
https://www.transportfever.net/filebase/index.php/Entry/226-TF-ID-Counter/

See this full guide for Passengers & Drivers : http://steamcommunity.com/sharedfiles/filedetails/?id=777208082

Drivers are specified witin the "seats" parameter. The first group of 3 numbers are rotation (turning left and right is the first, e.g. 20°) and the second group of 3 is the relative positions (offsets or scaling values in other places must be taken into account if used). "standing" can be "true" or "false". Also consider that the character will be move around a bit with animation.
{ group = 1, transf = transf.rotZYXTransl(transf.degToRad(20, 0.0, 0.0), vec3.new(-2.6,-0.20, 1.2)), crew = true, standing = true},
Sounds & Smoke
Sounds:
Sound files are .wav format, mono, 44.1KHz, 16bit
Located in ...\res\audio\effects\vehicle\ [ MOD ] \
Configuration of sounds in a .lua file located in ...\res\config\sound_set\
"horn" defines the horn/whistle.
The configuration is then called from the .mdl file by "soundSet" using the .lua filename (without the extension). E.g. :
soundSet = { name = "my_mod_sounds" }

Smoke / Steam Particle Effects:
3 instances is typical (for the chimney, and each piston at the sides), the vanila/stock models have up to 6. (But this could affect performance if over-done on the number of instances or frequency.)
Set these using "particleSystem":
  • frequency - how fast items are generated (bigger number = more smoke)
  • lifeTime - how long it lasts before fading out
  • position - 3 coordinates, to position relative to centre of the model (any offsets or scaling for meshes or groups should be taken into account)
  • size01 ( [ how big they start] , [ factor for how much they are scaled over time ] )
  • velocity - 3 dimensions, specifying which direction and how fast the items move (minus values reverse direction). Additionally there are also preset values which are applied by the game that always make the smoke rise.
Use trial and error in game when setting these (load a saved game). The engine should start from inside the depot to ensure it fully applies changes.
Animation
Animations and Events have parameters specified in all the hierarchy, e.g. .mdl, .grp and .msh.

To keep things simple; if you only have one Mesh with animation, list the Mesh with animation first and make it so it is part of the first Group listed (if using Groups).

In more complex uses; the position/order of the meshes and groups with animation should be specified by changing the number "[1]". Additionally, animations can also be sent to groups; the Model file gets the event trigger and can send it's own trigger to group files, which then triggers an animation in the mesh. (For an example of this see the game's bigboy locomotive, which uses this method.)

A common use is animating engine coupling linkage using the "drive" event:
In the .mdl file as a parameter within "lods" and must also put in the .grp file (if used):
events = { drive = { [1] = { forward = true, name = "drive", }, }

In the .msh file:
animations = { drive = { params = { keyframes = { { rot = { 0.0, 0.0, 0.0, }, time = 0.0, transl = { 0.0, 0.0, 0.0, }, }, -- *** Many more 'rot-time-transl' sets (with different values) go here *** }, origin = { 0.0, 0.0, 0.0, }, }, type = "KEYFRAME", }, },
17 animation steps/frames (including the first at 0) are typically used for this type of animation.
If you're smart with maths you can calculate the timings properly to match the game's turning of the wheels (it probably involves pi, wheels love pi). Otherwise trial and error can be used and a spreadsheet to calculate the intermediate steps (longer "time" values give 'slower' animation).

Animation Events for trains (etc):
drive
forward
backward - Is this ever used? Maybe for Multiple Unit Vehicles?
close_all_doors
open_all_doors
open_doors_left
close_doors_left
open_doors_right
close_doors_right
forever

Animation Events for planes:
open_flaps
close_flaps
open_wheels
close_wheels

For simple animations of steam engine rods, there are some built in functions which make things easier, see this guide:
https://steamcommunity.com/sharedfiles/filedetails/?id=315057617

Further information on Events (Google translate from German):
https://translate.google.co.uk/translate?hl=en&sl=de&u=https://www.transportfever.net/lexikon/index.php/Entry/97-Animationen-Events/&prev=search
Model Viewer & Testings
Model Viewer - Official overview : http://transportfever.com/wiki/doku.php?id=modding:developerinfo:tools

For a more detailed guide on setting up and using the Model Viewer, see:
http://steamcommunity.com/sharedfiles/filedetails/?id=1229955807

In addition to the main window of the viewer showing the model, there is log box (black cmd window) showing any error.
When first opening your mod you must go on the ".." item to go to the mods folder.
If textures are not found they will be listed as an error, but the model will load, albeit with the missing textures replaced with a default colour (or default values for MGA etc).
Whilst it's worth keeping HDR on, bear in mind it affects the brightness in a way that it might not in the game itself (the same goes for reflections of the background environment colour on high shine objects).
The viewer uses a surprising about of processor (always, even with no model opened), so if you leave it open when you're not using it, it will be in ur pc stealin ur cpuzzz...

Common Crashes:
If the viewer crashes with a Windows "has stopped working", don't close it straight away, check the log box for details of the error first.
  • Animation - After pressing play; Crashes with error text in the log box; this can be because the animation item is not first or the event is not in a group.
  • Missing mesh file - Crashes with no error text; if a corresponding .msh.blob doesn't exist for a .msh of the same name (e.g. you renamed one but not the other...)
  • Incorrect material type - Crashes with error text in the log box; related to mismatch between the "type" and a "params" in a .mtl file (e.g you set "PHYSICAL" but used "map_albedo_opacity" instead of "map_albedo" or mistyped one)

Other Debugging:
Texture Cache - if half of a texture is missing/weird or your changes aren't being applied, you can close the Model Viewer and delete its texture cache for your mod, in:
...Steam Games\steamapps\common\Transport Fever\model_viewer\texture_cache\mods\ [ YOUR MOD ]
If changes to maps (MGA etc) don't seem to be working or an item is really shiny, this can be because the file is named or specified wrong and they default values are getting applied instead.


Smoke, Sounds and "axle" turning can't be tested in the viewer (at the time of writing), check in game.
Individual cargo loads can't be checked in the viewer (at the time of writing), all types will be shown. (You can temporarily move the code for the other cargo types to another file to see just one type of cargo.) You must use a saved game (with the cargo routes set up) to test this.

UI Images are created by the Model Viewer by clicking Screenshot. (This requires the Model Viewer Vehicle Stage mod to be installed.)
Once created they will appear in: ...\Steam Games\steamapps\common\Transport Fever\model_viewer\screenshots\gui_icons\...
Move the "ui" folder into your mod in: ... [ YOUR MOD ] \res\textures\
(If you rename your .mdl file, you must rename the ui images to match.)

In-game testing:
You can create a small free-game (without your mod) and make a test line with 2 station, depot, some curves, and a raised embankment section and bridge (useful for close inspections), then save the game. Then load the saved game with you load mod (it if loads ok, save it again, with the mod, as a new file). It's best to always have the vehicle inside the the depot, rather than on a line, for test saved games (this forces it to reset for things). Be careful of adding a mod being tested to a real save game you're playing (save the game as new version so it can't get messed up).
Publishing to Steam (& Updating)
Publishing to Steam - Official Guide : http://transportfever.com/wiki/doku.php?id=modding:developerinfo:steamworkshop

Also see this guide on publishing:
https://steamcommunity.com/sharedfiles/filedetails/?id=796674359

Folder name; put _1 on the end of the mod folder name, to make it version 1.x , where x is the minor version in the mod.lua, e.g. "My Mod_1" will show as "My Mod v1.0" in game. (Numbers can't start with zero, e.g. 01 doesn't give v1.01.)

Preview images are need in the root folder, e.g.:
My Mod_1\workshop_preview.jpg - Typically 1280x720 (should be 16:9 ratio).
My Mod_1\image_00.tga - 240x135 (uncompressed).


Errors:
Error 2 - close TPF, open it again and have another try...

Updating a Published mod:
Once the mod has been published, to update it (rather than create a duplicate), it must have the ID number of the mod in a text file called "workshop_fileid.txt" in the root folder of the mod, e.g:
... [ YOUR MOD ] \workshop_fileid.txt
Get the mod ID by opening it your browser, the ID is the number in the URL, e.g. steamcommunity.com/sharedfiles/filedetails/?id=1234567890
When you update a mod, the Workshop description (and any changes you've made to it through Steam) will be overwritten (so copy your edited version to a text file first).

Remember you have a responsibility to be very careful to fully test your mod before updating on Steam, since people will now be using it in their games and will be rather unhappy if you break their game when they're 100 hours in...
Other Resources
For a detailed guide of 3D modeling, UV maps and texturing with Blender for Transport Fever (etc), see this guide (Google translate from German):
https://translate.googleusercontent.com/translate_c?depth=1&hl=en&prev=search&rurl=translate.google.co.uk&sl=de&sp=nmt4&u=https://www.transportfever.net/lexikon/index.php/Entry/115-Moddingleitfaden/&usg=ALkJrhgRmpj0i_4hLL1Yk4HumYYS9Chymw

Youtube Video English Tutorial on Modding Transport Fever by YstlDystl (including modelling in Blender, the Blender export plugin and setting up an asset in Transport Fever)
https://www.youtube.com/watch?v=tvTzZobYWWM&t=368

Youtube Video English Tutorial on Modding Transport Fever by Killakanz (setting up a locomotive in Transport Fever, including texture maps, animation and sounds)
https://www.youtube.com/watch?v=FnUwWMQbw2I

Youtube Videos on Train* Fever Modding by Ola Haldor (including 3D modelling)
https://www.youtube.com/watch?v=mFquueJxuLM
https://www.youtube.com/watch?v=AYsxOEQKVZ8
(*For a different version from Transport Fever, but many of the same princles.)

Forum threads with some useful bits of information and common specific problems:
http://steamcommunity.com/app/446800/discussions/2/1291817208499204803/
https://steamcommunity.com/app/446800/discussions/2/144513670978528565/
https://www.transportfever.net/index.php/Thread/3127-Blender-Modding-Help-ENGLISH-PLEASE/
Thanks
Much of the above is based on what many others have said in various places elsewhere, so thanks to them, in particular: killakanz, OlaHaldor, Gwinda.
< >
31 Comments
JK  [author] Jun 29 @ 2:52am 
@villavine10 - It's best to get the scale right when you first start making the model in the 3D software. You can correct the scale in the code, if needed, but it's more work.
villavine10 Jun 28 @ 8:53pm 
Do i have to scale before or after i start making my model, just a question to avoid headaches.
JK  [author] Jun 28, 2018 @ 8:41am 
I know it works on Assets (ASSET_TRACK), but I've never done anything with stations. Did you include 'forward', like this?:
events = {
forever = {
[0] = {
forward = true,
name = "animation_name",
}
},
},
Maybe have a look at the code for the game's harbours as they have animated cranes.
Vacation Days on Main Jun 28, 2018 @ 6:55am 
Hmmm, Do you know an Animation Trigger i can use for a Door of a Train Station that should open and close randomly?

I tried default and forever with no succses.
TardisITguy Jun 18, 2018 @ 2:07pm 
Thank you JK Again Awesome Guide and help to boot. :)
JK  [author] Jun 17, 2018 @ 6:41am 
@TardisITguy - Those missing textures won't cause a crash. The other appears to be related to Stations and Cargo. I don't know any more than that. You could look at which stations you have installed and which have been updated recently. Otherwise post in the Support Discussion section and someone may be able to solve it.
TardisITguy Jun 17, 2018 @ 6:16am 
Actually I think I found where the error really is, but could use some assistance in translating.

c:\build\transport_fever\steam\transport_fever_release\src\game\ecs\simcargoatterminalsystem.cpp:240: int __cdecl ecs::SimCargoAtTerminalSystem::GetPlace(const struct transport::EdgeId &,int) const: Assertion `edgeInfo.cargoType == cargoType' failed.
TardisITguy Jun 17, 2018 @ 6:07am 
Awesome m8. Thank you very much. So as I look through the file, I see the following, it would seem these are the "error" causing the crash, but I know while these may be the direct cause, it may just be a symptom of another issue. Any thoughts would be appreciated. I'm not sure what mod these are coming from, the beginning notes all the mods by number but only lists "Flexible Industries mod: v1.1.23 @ 06/17/18 07:29:15" by name.

error loading dds file: res/textures/ground_texture/farmland_marron_01_nrml.dds
error loading dds file: res/textures/ground_texture/farmland_vert_03_nrml.dds
error loading dds file: res/textures/ground_texture/farmland_vert_02_nrml.dds
error loading dds file: res/textures/ground_texture/farmland_jaune_01_nrml.dds

JK  [author] Jun 17, 2018 @ 4:51am 
@TardisITguy - These are in ...Steam\userdata\< USER ID >\446800\local\crash_dump\ the .txt files are human readable.
TardisITguy Jun 17, 2018 @ 4:03am 
Great Guidde JK, Thank you. Do you know if there is a crash log somewhere in the main games file structure? I have a few mods and I'm hoping it will tell me which of them is causing the issue.