This shows you the differences between two versions of the page.
modding:developerinfo:maps [2019/03/19 10:18] |
modding:developerinfo:maps [2019/03/19 10:18] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ===== Maps ===== | ||
+ | ==== Overview ==== | ||
+ | |||
+ | In addition to random maps, it's possible to create custom maps. The only thing you need is a heightmap in form of a greyscale image. In an accompanying ''map.lua'' file you can specify the height range of your heightmap and it's possible to add towns and industries. | ||
+ | |||
+ | Each map has its own separate folder and there is a specific directory for custom maps. The structure looks as follows: | ||
+ | |||
+ | <code> | ||
+ | Transport Fever\ | ||
+ | ... | ||
+ | maps\ | ||
+ | test_map01\ | ||
+ | heightmap.png | ||
+ | map.lua | ||
+ | test_map02\ | ||
+ | ... | ||
+ | ... | ||
+ | ... | ||
+ | </code> | ||
+ | |||
+ | ==== Heightmap ==== | ||
+ | |||
+ | The heightmap used to create a custom map is represented by a greyscale image. Each pixels brightness represents a height value. The range of these values can be set in the accompanying ''maps.lua'' file. | ||
+ | |||
+ | Restrictions for the greyscale image: | ||
+ | * greyscale, i.e. should contain only one channel | ||
+ | * PNG format | ||
+ | * 8-/16-bit | ||
+ | |||
+ | The width and heigth of the image should be multiples of 256 plus one and are limited to be between 257 and 16385. | ||
+ | The total number of pixels should be at most 16 millions, for example ''4097 x 4097'' or ''2049 x 8193'' (note ''256 x 16 + 1 = 4097'' or ''256 x 32 + 1 = 8193''). | ||
+ | |||
+ | Greyscale image heightmaps can be found on the internet or created with standard image editing tools (Photoshop, Gimp, etc.). | ||
+ | |||
+ | ==== Mapinfo ==== | ||
+ | |||
+ | Every custom map needs an accompanying ''maps.lua'' file, where you at least need to specify a name. Otherwise, it will not show up in the "Create New Game" dialog. It's also highly recommended to define the range of the height values represented by the heightmap. | ||
+ | |||
+ | A typical ''map.lua'' file: | ||
+ | |||
+ | <code lua> | ||
+ | function data() | ||
+ | return { | ||
+ | name = "test_map01", -- (1) | ||
+ | range = { 10.0, 510.0 }, -- (2) | ||
+ | seed = "test", -- (3) (optional) | ||
+ | startDate = { year = 1950, month = 1, day = 1 }, -- (4) (optional) | ||
+ | towns = { -- (5) (optional) | ||
+ | { pos = { -800.0, 150.0 }, name = "Schaffhausen", sizeFactor = 1.0 }, | ||
+ | ... | ||
+ | }, | ||
+ | industries = { -- (6) (optional) | ||
+ | { pos = { -1500.0, 1600.0 }, fileName = "industry/farm.con" }, | ||
+ | ... | ||
+ | } | ||
+ | } | ||
+ | end | ||
+ | </code> | ||
+ | |||
+ | - Name of the map that appears in the selection menu | ||
+ | - Sets minimum (black pixel) and maximum height (white pixel), where: | ||
+ | * water level is always at 100 m | ||
+ | * maximum allowed height is 1000 m | ||
+ | - Fix seed to a specific value | ||
+ | - Override start date | ||
+ | - List of towns | ||
+ | - List of industries |