User Tools

Site Tools

Urban Games



Transport Fever 2 has the ability to define different climate zones. They vary in the look and feel of the environment, as they have different plants, colors, terrain textures and lighting.


A climate zone is defined in a .lua file in the res/config/climate/ folder. Usually they are called <climatename>.clima.lua. The file has the following setup:

function data() 
return {
  id = "temperate",
  name = _("Temperate"),
  desc = _("Mixed forest vegetation"),
  vehicleSet = "europe",
  order = 1,
  mapColoring = {...},
  groundTextures = {...},
  skirt = {...},
  updateFn = function(params)

While id is a unique technical identifier, name and desc are strings which can be translated in a strings.lua file. The vehicleSet property is a reference to the vehicle set that should be preselected in the main menu dialogs. The climat zones are ordered in the dialogs according to their order values. The default climates use the order indices 1,2 and 3.

The mapColoring block defines the colors that are used for the map preview in terrain generator dialogs. It has several properties:

  • levels is a list of level definitions. Each level stands for a color at a certain height and consists of two values:
    • color is a color definition with three values between 0 and 1. It is possible to use the maputil.MakeColor(r,g,b) function in the maputil.lua script to convert from 255 based colors.
    • height is the heightlevel at which this color should be used. Intermediate height levels are interpolated between colors.
  • waterColor0 is the color definition for the shallow water in the shore area.
  • waterColor1 is the color definition for the deep water area.
  • ambientColor is the color definition for the overall color grading of the preview map.
  • sunColor is the color definition for the sun exposure.

The groundTextures block is used to assign special ground textures for several purposes. The references are all relative to res/config/ground_texture/:

  • waterGround is the texture that is used below water, e.g. in lakes and rivers.
  • waterShore is the border texture that is used along the shoreline.
  • farmland is the texture used for for farmland areas.
  • farmlandBorder is the texture used for the border around the farmland areas.

The skirt block is used to define the textures used for the edges of the game world. It is common that functions of the texutil.lua from the res/scripts/ folder are used to provide the texture maps for the skirt block.

1 colorTex is the texture map that is used as base colors for the edge faces.
2 detailTex is the texture map that is used as overlay to get some randomzation of colors at the faces.
3 waterText is the texture map that is used as base color for the areas of edge faces that touch water.

The updateFn is used to generate the terrain textures all over the map.


The updateFn is a function that is called after every change of terrain to recalculate the default terrain texture distribution over the map. It gets several parameters in a data struct:

layers generated by updateFn

key type description
bounds.max.x integer The maximum value of map bounds in x direction
bounds.max.y integer The maximum value of map bounds in y direction
bounds.min.x integer The minimum value of map bounds in x direction
bounds.min.y integer The minimum value of map bounds in y direction
mapSizeX integer The actual map size in x direction
mapSizeY integer The actual map size in y direction
waterLevel integer The height of water level

The expected return data struct contains a mixingLayer property that contains several terrain texture layers:

  -- intermediate results
  mixingLayer = {
    backgroundMaterial = "grass_light_green.lua",
    layers = {
      -- Standard grass
        map = layer2Map,
        dither = true,
        material = "grass_green.lua",
      -- Slope rocks
      -- Beach materials
      -- River materials

no dithering and dithering

The material references are all relative to res/config/terrain_material/. The one referenced at backgroundMaterial is painted as a primer all over the map. The layers below are painted over it, layer by layer in the order they have in the list. Each layer has three properties:

  • map is a data map that was computated before. It serves as a mask for the terrain material.
  • dither enables the dithering effect at the edges of the texture.
  • material is the reference to a terrain material.

The map layers usually are computed by using the layersutil.lua that can be found in res/scripts/terrain/ folder. It provides a lot of operations which can be used to generate the mask maps.

UI Icons

The ui icons for climates are used in some main menu dialogs. They are located in the res/textures/ui/climate/ folder and are named <climatename>@2x.tga. Their resolution should be 300×200 pixels.

modding/climates.txt · Last modified: 2020/06/20 11:10 by yoshi