Module api.util

Contains generic util functions that are not associated with a specific game instance.

All functions in this namespace can be called from anywhere.

Functions

formatForce(number) Formats a number as force with the correct locale.
formatLength(length) Formats a distance with the correct locale and unit of measurement.
formatMoney(money) Formats a money amount with the correct locale and currency.
formatNumber(number) Formats a number with the correct locale.
formatPower(number) Formats a number as power with the correct locale.
formatSpeed(speed) Formats a speed value with the correct locale and unit of measurement.
formatweight(number) Formats a number as weight with the correct locale.
getAppConfig() Returns the game settings
getBuildVersion() Returns the build version
getKeyName(keyCommand) Returns the key sequence associated to the command.
getLanguage() Returns the current language settings
getLuaUsedMemory() Obtains the total used memory by this lua state.
getUiMode() Funcion to be used to obtain the actual UiMode of the apllication


Functions

formatForce(number)
Formats a number as force with the correct locale.

Parameters:

  • number long The number in kN

Returns:

    string with formatted number
formatLength(length)
Formats a distance with the correct locale and unit of measurement. Defaults to meters unless the user selected another system of measurement.

Parameters:

  • length float distance in meters

Returns:

    string with formatted distance
formatMoney(money)
Formats a money amount with the correct locale and currency.

Parameters:

  • money long amount of money

Returns:

    string with formatted amount of money
formatNumber(number)
Formats a number with the correct locale.

Parameters:

  • number long

Returns:

    string with formatted number
formatPower(number)
Formats a number as power with the correct locale.

Parameters:

  • number long The number in kW

Returns:

    string with formatted number
formatSpeed(speed)
Formats a speed value with the correct locale and unit of measurement. Defaults to km/h unless the user selected another system of measurement.

Parameters:

  • speed float speed in meter per second

Returns:

    string with formatted speed
formatweight(number)
Formats a number as weight with the correct locale.

Parameters:

  • number long The number in metric tons

Returns:

    string with formatted number
getAppConfig()
Returns the game settings

Returns:

    type.AppConfig game settings
getBuildVersion()
Returns the build version

Returns:

    string the build version
getKeyName(keyCommand)
Returns the key sequence associated to the command. See the ''settings.lua'' file in the userdata local folder for a list of all available key commands.

Parameters:

  • keyCommand string the command to which the key sequence is associated.

Returns:

    string the key sequence associated with the given key command

Usage:

    api.util.getKeyName("constructOptPrecise1")
getLanguage()
Returns the current language settings

Returns:

    table language settings
getLuaUsedMemory()
Obtains the total used memory by this lua state.

Returns:

    int used memory in kb
getUiMode()
Funcion to be used to obtain the actual UiMode of the apllication

Returns:

    type.UiMode Return actual used by the application UiMode.
generated by LDoc 1.4.3 Last updated 2023-04-18 15:10:38