config.Class object
Object table CLASS_TABLE in core/libraries/sh_config.lua
Summary
Methods
CONFIG[key].'value', 'default' or 'isShared'.Methods
CLASS_TABLE:__call(parameter, failSafe)
shared gamemodes/catwork/gamemode/core/libraries/sh_config.lua:33Queries a field of the config entry when the config object is called like a function.
local default = config.Get('cash_enabled')('default')
Parameters
- parameter String Field of the config entry to read, e.g.
'default'or'isShared' - failSafe Any optional, defaults to
nilValue returned when the field is not set
Returns
- Any The field's value, or
failSafe
See also
Converts the config object to a string of the form CONFIG[key].
Returns
- String The string representation
Creates a new config object wrapping the stored entry for a key.
The object is created even when no entry exists for the key; check it with CLASS_TABLE:IsValid.
Use config.Get instead, which caches the objects.
Parameters
- key String The config key
Returns
- Config The new config object
Returns the config's current value.
if config.Get('cash_enabled'):Get(false) then
print('Cash is enabled.')
end
Parameters
- failSafe Any optional, defaults to
nilValue returned when the entry does not exist or has no value
Returns
- Any The current value, or
failSafe
See also
Returns the config's value as a boolean.
true, 'true', 'yes', '1' and 1 count as true; every other value is false.
Parameters
- failSafe Boolean optional, defaults to
nilValue returned when the entry does not exist;falsewhen not given
Returns
- Boolean The value as a boolean
Returns the config's default value, the value it was added with.
Parameters
- failSafe Any optional, defaults to
nilValue returned when the entry does not exist
Returns
- Any The default value, or
failSafe
Returns the value the config will take after the next restart.
Only set for keys added with needsRestart whose value was changed while the server was running.
Parameters
- failSafe Any optional, defaults to
nilValue returned when no next value is pending
Returns
- Any The pending value, or
failSafe
Returns the config's value as a number.
Parameters
- failSafe Number optional, defaults to
nilValue returned when the entry does not exist or its value is not numeric;0when not given
Returns
- Number The value as a number
Returns the config's value converted to a string.
Parameters
- failSafe String optional, defaults to
nilValue returned when the entry does not exist;''when not given
Returns
- String The value as a string
Returns whether the config object wraps an existing config entry.
Returns
- Boolean Whether the key has been added with
config.Add
Returns a field of the config entry, such as 'value', 'default' or 'isShared'.
Parameters
- key String Name of the field to read
- failSafe Any optional, defaults to
nilValue returned when the entry or the field does not exist
Returns
- Any The field's value, or
failSafe
CLASS_TABLE:Set(value, map, forceSet, temporary)
shared gamemodes/catwork/gamemode/core/libraries/sh_config.lua:610On the server
Sets the config's value, saving and networking it.
The value is converted to the type of the current value; '!default' resets it to the default.
Static keys only change when forceSet is true. For keys that need a restart, the value is
stored as the next value instead once the config has initialized. Shared keys are sent to every
player and ClockworkConfigChanged is fired when the value changes.
A value set for a map is kept in config.map and saved to that map's own config file.
Parameters
- value Any The new value, or
'!default' - map String optional, defaults to
nilOnly apply the value on this map - forceSet Boolean optional, defaults to
nilIgnore the static and restart flags - temporary Boolean optional, defaults to
nilDo not save the value
Returns
- Any The converted value, or
nilwhen the entry does not exist or the value is invalid
On the client
Sets the config's value on the client.
The value is converted to the type of the current value, and values of another type are
rejected; '!default' resets it to the default. Fires ClockworkConfigChanged when the value
changes after initialization.
Parameters
- value Any The new value, or
'!default'
Returns
- Any The new value, or
nilwhen the entry does not exist or the value is invalid