GetConfigValue
This function was added in DSL 1
Description
Return the raw value associated with key as a string. If there is no value, defaultValue will be returned (if given).
function GetConfigValue(config, key, defaultValue) --[[ ... ]] end
Parameters
config:userdata- The configuration object to query.key:string- The key to look up in the configuration.defaultValue?:any- (Optional) The value to return if the key does not exist in the configuration. If not provided,nilwill be returned.
Return Values
value:string?- The raw value associated with the key as a string, ornilif the key does not exist and no default value is provided. If a default value is provided, it will return that instead.
Example
local config = LoadConfigFile('my_config.ini')
local serverName = GetConfigValue(config, 'server_name', 'Default Server')
if serverName then
print('Server Name: ' .. serverName)
else
print('Server Name not set, using default value.')
end