Class that handles all game settings related functions.
More...
#include <script_gamesettings.hpp>
|
static bool | IsValid (string setting) |
| Is the given game setting a valid setting for this instance of OpenTTD?
|
|
static int | GetValue (string setting) |
| Gets the value of the game setting.
|
|
static bool | SetValue (string setting, int value) |
| Sets the value of the game setting.
|
|
static bool | IsDisabledVehicleType (GSVehicle::VehicleType vehicle_type) |
| Checks whether the given vehicle-type is disabled for companies.
|
|
Class that handles all game settings related functions.
- Note
- GSGameSettings::IsValid and GSGameSettings::GetValue are functions that rely on the settings as OpenTTD stores them in savegame and openttd.cfg. No guarantees can be given on the long term validity, consistency and stability of the names, values and value ranges. Using these settings can be dangerous and could cause issues in future versions. To make sure that a setting still exists in the current version you have to run GSGameSettings::IsValid before accessing it.
-
The names of the setting for GSGameSettings::IsValid and GSGameSettings::GetValue are the same ones as those that are shown by the list_settings command in the in-game console. Settings that are string based are NOT supported and GameSettings::IsValid will return false for them. These settings will not be supported either because they have no relevance for the script (default client names, server IPs, etc.).
◆ GetValue()
static int GSGameSettings::GetValue |
( |
string |
setting | ) |
|
|
static |
Gets the value of the game setting.
- Parameters
-
setting | The setting to get the value of. |
- Precondition
- IsValid(setting).
- Warning
- Results of this function are not governed by the API. This means that the value of settings may be out of the expected range. It also means that a setting that previously existed can be gone or has changed its name/characteristics.
- Note
- Results achieved in the past offer no guarantee for the future.
- Returns
- The value for the setting.
◆ IsDisabledVehicleType()
Checks whether the given vehicle-type is disabled for companies.
- Parameters
-
vehicle_type | The vehicle-type to check. |
- Returns
- True if the vehicle-type is disabled.
◆ IsValid()
static bool GSGameSettings::IsValid |
( |
string |
setting | ) |
|
|
static |
Is the given game setting a valid setting for this instance of OpenTTD?
- Parameters
-
setting | The setting to check for existence. |
- Warning
- Results of this function are not governed by the API. This means that a setting that previously existed can be gone or has changed its name.
- Note
- Results achieved in the past offer no guarantee for the future.
- Returns
- True if and only if the setting is valid.
◆ SetValue()
static bool GSGameSettings::SetValue |
( |
string |
setting, |
|
|
int |
value |
|
) |
| |
|
static |
Sets the value of the game setting.
- Parameters
-
setting | The setting to set the value of. |
value | The value to set the setting to. The value will be clamped to MIN(int) .. MAX(int). |
- Precondition
- IsValid(setting).
- Returns
- True if the action succeeded.
- Note
- Results achieved in the past offer no guarantee for the future.