Table of Contents

Climates

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.

Configuration

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)
}
end

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:

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

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.

UpdateFn

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:

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.