GetConfigBoolean
This function was added in DSL 1
Description
Return if the value under key is not false.
If there is no value, defaultValue will be returned (if given).
This function retrieves a boolean value from a configuration object based on the provided key. If the key does not exist or the value is not a boolean, it returns the specified default value if provided, or false if no default is specified.
function GetConfigBoolean(config, key, defaultValue) --[[ ... ]] end
Parameters
config:userdata- The configuration object from which to retrieve the value.key:string- The key for which the boolean value is to be retrieved.defaultValue?:any- (Optional) The value to return if the key does not exist or the value is not a boolean. If not provided, defaults tofalse.
Return Values
value:boolean?- The boolean value associated with the key, or the default value if the key does not exist or is not a boolean.
Example
local config = LoadConfigFile('my_config.ini')
local isFeatureEnabled = GetConfigBoolean(config, 'feature_enabled', false)
if isFeatureEnabled then
print('Feature is enabled')
else
print('Feature is disabled')
end