Config
The Config namespace provides helpers for reading, writing, and saving script configuration data.
Functions
GetConfig(configName: string){ [key: string]: any; }
Retrieves a config object by its name.
configNamestring - The name of the configuration object.
IMPORTANT
After changing the config object, you must call SaveConfig to save the changes.
Returned:
- { [key: string]: any; } - The configuration object.
SaveConfig(configName: string)void
Saves a configuration object by its name.
configNamestring - The name of the configuration object.
Read(configName: string, key: string, defaultValue: any)any
Reads a value from a configuration object. If the value does not exist, it returns a default value.
configNamestring - The name of the configuration object.keystring - The key of the value to read.defaultValueany - The default value to return if the key does not exist.
IMPORTANT
If the value is a string, it will be parsed as JSON.
Returned:
- any - The value from the configuration object or the default value.
ReadRaw(configName: string, key: string, defaultValue: any)any
Reads a raw value from a configuration object. If the value does not exist, it returns a default value.
configNamestring - The name of the configuration object.keystring - The key of the value to read.defaultValueany - The default value to return if the key does not exist.
IMPORTANT
If the value is a string, it will not be parsed as JSON.
Returned:
- any - The raw value from the configuration object or the default value.
ReadInt(configName: string, key: string, defaultValue: number)number
Reads an integer value from a configuration object. If the value does not exist, it returns a default value.
configNamestring - The name of the configuration object.keystring - The key of the value to read.defaultValuenumber - The default value to return if the key does not exist.
Returned:
- number - The integer value from the configuration object or the default value.
ReadFloat(configName: string, key: string, defaultValue: number)number
Reads a floating point value from a configuration object. If the value does not exist, it returns a default value.
configNamestring - The name of the configuration object.keystring - The key of the value to read.defaultValuenumber - The default value to return if the key does not exist.
Returned:
- number - The floating point value from the configuration object or the default value.
ReadString(configName: string, key: string, defaultValue: string)string
Reads a string value from a configuration object. If the value does not exist, it returns a default value.
configNamestring - The name of the configuration object.keystring - The key of the value to read.defaultValuestring - The default value to return if the key does not exist.
Returned:
- string - The string value from the configuration object or the default value.
Write(configName: string, key: string, value: any)void
Writes a value to a configuration object and saves it.
configNamestring - The name of the configuration object.keystring - The key of the value to write.valueany - The value to write.
WriteRaw(configName: string, key: string, value: any)void
Writes a raw value to a configuration object and saves it.
configNamestring - The name of the configuration object.keystring - The key of the value to write.valueany - The value to write.
IMPORTANT
Directly writes the value to the configuration object.
WriteInt(configName: string, key: string, value: number)void
Writes an integer value to a configuration object and saves it.
configNamestring - The name of the configuration object.keystring - The key of the value to write.valuenumber - The integer value to write.
WriteFloat(configName: string, key: string, value: number)void
Writes a floating point value to a configuration object and saves it.
configNamestring - The name of the configuration object.keystring - The key of the value to write.valuenumber - The floating point value to write.
WriteString(configName: string, key: string, value: string)void
Writes a string value to a configuration object and saves it.
configNamestring - The name of the configuration object.keystring - The key of the value to write.valuestring - The string value to write.