Parameter types in constructions

Willkommen in der Transport Fever Community

Welcome to the fan community of Transport Fever and Train Fever, the economic simulators of Urban Games. The community is free for you to share and inform yourself about the game. We cultivate a friendly and objective interaction with each other and our team will be happy to answer any questions you may have.

 

Registration and use is of course free for you.

 

We wish you a lot of fun and hope for active participation.

The Team of the Transport-Fever Community

  • With Transport Fever 2 there are some new parameter types that can be used for constructions.

    All parameter types have common properties:


    PropertyValueDefaultDescription
    keyStringmandatoryunique identifier for the parameter
    nameString""Display name for the parameter menu
    values{String,String,...}mandatoryDisplay values for the parameter menu, see below
    defaultIndexInteger0Pre-selected option on first call
    uiType"BUTTON" or "SLIDER" or "COMBOBOX" or "ICON_BUTTON" or "CHECKBOX""BUTTON"Type of parameter, see below
    yearFromInteger0Parameter is displayed from
    yearToIntegerinfiniteParameter is displayed until
    tooltipString""Tooltip that is displayed above the parameter name when hovering



    The characteristics of the different types are considered below:


    BUTTON
    Simple text buttons are already known from Transport Fever. They are lined up in the menu as a centered list. The labels of the buttons are passed as a string list in the values parameter, they can also be translated in strings.lua.

    Code
    1. {
    2. key = "typ",
    3. name = _("Grabstein / Kreuz"),
    4. uiType = "BUTTON",
    5. values = { _("Grabstein"), _("Kreuz"), _("nichts"), },
    6. tooltip = _("Wähle den Aufbau für das Grabmal"),
    7. defaultIndex = 0,
    8. },

    In the game the above code looks like this:



    SLIDER
    Especially for many linear values, such as numerical series or size increments, sliders can be used as easy-to-use controllers. The name of the currently selected position is displayed to the right of the slider. The display names of the buttons are passed as a string list in the values parameter, these can also be translated in the strings.lua.

    Code
    1. {
    2. key = "mauerlaenge",
    3. name = _("Länge der Mauer"),
    4. uiType = "SLIDER",
    5. values = { _("1"), _("2"), _("3"), _("4"), _("5"), _("6"), _("7"), _("8"), },
    6. tooltip = _("Wähle die Anzahl der Mauerelemente"),
    7. defaultIndex = 7,
    8. },

    In the game the above code looks like this:



    COMBOBOX
    If a large number of text options should be available, a simple list of buttons is not sufficient. Then a combo box, also known as a drop-down menu, can be implemented to offer a compact number of options. The entries of the list are passed as a string list in the values parameter, they can also be translated in strings.lua.

    Code
    1. {
    2. key = "tortyp",
    3. name = _("Tortyp"),
    4. uiType = "COMBOBOX",
    5. values = { _("mit Kreuz"), _("ohne Kreuz"), _("ohne Kreuz - offen"), },
    6. tooltip = _("Wähle die Art des Friedhoftors"),
    7. defaultIndex = 0,
    8. },

    In the game the above code looks like this:



    ICON_BUTTON
    Unlike the text buttons, the icon buttons display small images in TGA format. Unlike the text buttons, the list is currently left-aligned. If the list of buttons becomes wider than the parameter menu, it will wrap to another line. It is therefore advisable that the images for the buttons all have the same height. Also, the border of the buttons should be transparent so that you can see which option is currently selected. The file paths to the images are passed as a string list in the values parameter, the paths refer to the complete texture folder (see example)

    Code
    1. {
    2. key = "stein_mat",
    3. name = _("Grabsteinmaterial"),
    4. uiType = "ICON_BUTTON",
    5. values = {"ui/parameters/grabstein_schwarz.tga", "ui/parameters/grabstein_grau.tga", "ui/parameters/grabstein_weiss.tga", "ui/parameters/grabstein_rot.tga", },
    6. tooltip = _("Wähle das Material für den Grabstein"),
    7. defaultIndex = 0,
    8. },

    In the game the above code looks like this:



    CHECKBOX
    If only one value is assigned with yes or no, a checkbox is also suitable as parameter type. Only the name is displayed, but the values parameter must still be defined with two values, but it's values are never shown.

    Code
    1. {
    2. key = "random",
    3. name = _("Zufällige Kombination der Grabmäler"),
    4. uiType = "CHECKBOX",
    5. values = {"0", "1"},
    6. tooltip = _("Lege fest, ob die Grabmäler zufällig zusammengestellt werden"),
    7. },

    In the game the above code looks like this:



    Return values of the parameters
    In the updateFn-function of the Construction the selected options can be called up with params.<key>. Numbers starting from 0 are displayed. The first entry of a dropdown, for example, returns a 0. For a checkbox, 0 corresponds to the non-activated state, 1 to the activated state.

Share