Groups for the buy menu are passively defined in Transport Fever 2, i.e. a group is not explicitly defined with the contents contained in a separate file. Instead, the vehicles are optionally specified to be included in a group (and in which group). Only then will a purchase menu entry be displayed as a group.
[h1]Code adaptation in *.mdl files[/h1]
The group is entered in the transportVehicle code block. The keyword to be used is groupFileName. The path to any mdl, which is to serve as a group entry in the purchase list, must be specified relative to the models folder. An example looks like this:
transportVehicle = {
carrier = "RAIL",
compartmentsList = {
-- ...
},
loadSpeed = 1,
multipleUnitOnly = false,
reversible = false,
groupFileName = "vehicle/train/menu_1020.mdl",
},
In the game such a grouping is indicated by the reference to n variants in the upper right corner of the group entry. In the right column you will then find another list with the variants contained in these groups in the lower area. The technical data shows the values of the currently selected variant in the group.
[h1]Code adaptation in *.lua files of multiple units[/h1]
The group is entered in the return code block. The keyword to use is also groupFileName. Behind it is the path:
- relative to the models folder if a model is to serve as a group.
- relative to the config/multiple_unit folder if another train is to serve as a group.
An example looks like this:
function data()
return {
vehicles = {
-- ...
},
groupFileName = "vehicle/train/menu_cityjet.mdl",
name = _("oebb_4744_name"),
desc = _("oebb_4746_desc")
}
end
In the case of multiple-unit trains, the representation looks exactly the same as for individual vehicles. Here, too, such a grouping is indicated by the reference to n variants in the upper right corner of the group entry. In the right column you will then find another list with the variants contained in these groups in the lower area. The technical data shows the values of the currently selected variant in the group.
[h1]Individual group pictures and names[/h1]
Especially for vehicles with many colour variations one would like to show in the group entry what one can expect in the group. Therefore it is necessary to create an individual menu model as a placeholder, which is never displayed in the game itself as a variant to buy. This model gets the name of the desired group and the preview image is saved as ui image in the ui\models_small folder. In the code it is important that the multipleUnitOnly entry is set to true. As long as no multiple unit contains the model, this means that the entry itself is never offered for sale, but only appears if a subordinate train or model is available. It is important that the groupFileName is not set for this model:
transportVehicle = {
carrier = "RAIL",
compartmentsList = {
-- ...
},
loadSpeed = 1,
multipleUnitOnly = true,
reversible = false,
-- groupFileName not set!
},
The examples described in the previous sections each use an individualised menu item according to this scheme.
To support a common style, here is a suggestion for the grouping sprite:
- Take up to 4 of the available variants
- Place them 30 pixels apart of each other with the right one being at the front
- Make an approximately 2 pixel wide gap between the variants to improve the contrast
- For multiple units, use 50 - 100 % of the second coach, too
- In the normal size of the purchase menu, the images can be a maximum of 327 pixels wide. Then the menu is stretched accordingly. Starting from 700 pixels the right edge is cut off
[h1]Different availability, other modes of transport and engine types[/h1]
For vehicles with a long development time, it is not necessary for the group model to cover the availability range of all variants. If only one variant is available at a time, it is displayed individually in the purchase list. As soon as two or more variants are available, the group entry with the variant list is displayed.
Grouping is not only possible for rail vehicles. It can also be used for other vehicle types (aircraft, ships, road (rail) vehicles).
For rail vehicles, there is also the special case that different variants of a group have defined diesel and other electrical equipment as drive types, for example. If in the purchase menu the tab is set to "ALL", all are displayed under the group. If diesel vehicles have been explicitly selected, only the corresponding subset of the vehicles is displayed.