Summary

Methods

Queries a field of the config entry when the config object is called like a function.
Converts the config object to a string of the form CONFIG[key].
Creates a new config object wrapping the stored entry for a key.
Returns the config's current value.
Returns the config's value as a boolean.
Returns the config's default value, the value it was added with.
Returns the value the config will take after the next restart.
Returns the config's value as a number.
Returns the config's value converted to a string.
IsValid()shared
Returns whether the config object wraps an existing config entry.
Returns a field of the config entry, such as 'value', 'default' or 'isShared'.
Sets the config's value, saving and networking it.

Methods

CLASS_TABLE:__call(parameter, failSafe)

shared gamemodes/catwork/gamemode/core/libraries/sh_config.lua:33

Queries 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 nil Value 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 nil Value returned when the entry does not exist or has no value

Returns

  • Any The current value, or failSafe

See also

CLASS_TABLE:GetBoolean(failSafe)

shared gamemodes/catwork/gamemode/core/libraries/sh_config.lua:79

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 nil Value returned when the entry does not exist; false when not given

Returns

  • Boolean The value as a boolean

CLASS_TABLE:GetDefault(failSafe)

shared gamemodes/catwork/gamemode/core/libraries/sh_config.lua:116

Returns the config's default value, the value it was added with.

Parameters

  • failSafe Any optional, defaults to nil Value 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 nil Value returned when no next value is pending

Returns

  • Any The pending value, or failSafe

CLASS_TABLE:GetNumber(failSafe)

shared gamemodes/catwork/gamemode/core/libraries/sh_config.lua:94

Returns the config's value as a number.

Parameters

  • failSafe Number optional, defaults to nil Value returned when the entry does not exist or its value is not numeric; 0 when not given

Returns

  • Number The value as a number

CLASS_TABLE:GetString(failSafe)

shared gamemodes/catwork/gamemode/core/libraries/sh_config.lua:105

Returns the config's value converted to a string.

Parameters

  • failSafe String optional, defaults to nil Value 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

CLASS_TABLE:Query(key, failSafe)

shared gamemodes/catwork/gamemode/core/libraries/sh_config.lua:66

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 nil Value 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:610

On 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 nil Only apply the value on this map
  • forceSet Boolean optional, defaults to nil Ignore the static and restart flags
  • temporary Boolean optional, defaults to nil Do not save the value

Returns

  • Any The converted value, or nil when 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 nil when the entry does not exist or the value is invalid

Defined in

Defined in