a3_vemf_reloaded/exile_vemf_reloaded/functions/fn_getSetting.sqf

110 lines
2.4 KiB
Plaintext
Raw Normal View History

2016-04-06 16:04:51 +00:00
/*
Author: IT07
Description:
gets config value of given var from VEMF config OR cfgPath
Params:
method 1:
_this: STRING - SINGLE config value to get from root of CfgVemfReloaded
method 2:
_this select 0: ARRAY of STRINGS - MULTIPLE config values to get from root of VEMFconfig
method 3:
_this select 0: ARRAY of STRINGS - config path to get value from. Example: "root","subclass"
_this select 1: ARRAY of STRINGS - MULTIPLE config values to get from given path
Returns:
ARRAY - Result
*/
2016-04-13 20:28:31 +00:00
private["_r","_check","_v"];
2016-04-06 16:04:51 +00:00
_r = [];
_check =
{
if (isNumber _cfg) then
{
_v = getNumber _cfg
2016-04-13 20:28:31 +00:00
} else
2016-04-06 16:04:51 +00:00
{
if (isText _cfg) then
{
_v = getText _cfg
2016-04-13 20:28:31 +00:00
} else
2016-04-06 16:04:51 +00:00
{
if (isArray _cfg) then
{
_v = getArray _cfg
};
};
};
};
if (_this isEqualType "") then
{
2016-04-13 20:28:31 +00:00
private ["_cfg"];
2016-04-10 15:25:24 +00:00
if (isNull (configFile >> "CfgVemfReloaded" >> "CfgSettingsOverride" >> _this)) then
{
_cfg = configFile >> "CfgVemfReloaded" >> _this;
} else
{
_cfg = configFile >> "CfgVemfReloaded" >> "CfgSettingsOverride" >> _this;
};
2016-04-06 16:04:51 +00:00
call _check;
2016-04-13 20:28:31 +00:00
if not isNil"_v" then
2016-04-06 16:04:51 +00:00
{
_r = _v;
};
};
if (_this isEqualType []) then
{
2016-04-10 15:25:24 +00:00
if (_this isEqualTypeArray [[],[]]) then
2016-04-06 16:04:51 +00:00
{
2016-04-13 20:28:31 +00:00
private ["_path","_build"];
2016-04-10 15:25:24 +00:00
_path = _this select 0;
//["fn_getSetting", 1, format["_path = %1", _path]] spawn VEMFr_fnc_log;
2016-04-13 20:28:31 +00:00
_build =
{
2016-04-10 15:25:24 +00:00
{
_cfg = _cfg >> _x;
} forEach _path;
};
2016-04-06 16:04:51 +00:00
{
2016-04-13 20:28:31 +00:00
private ["_cfg"];
2016-04-10 15:25:24 +00:00
_cfg = configFile >> "CfgVemfReloaded" >> "CfgSettingsOverride";
call _build;
_cfg = _cfg >> _x;
//["fn_getSetting", 1, format["_cfg after first build = %1", _cfg]] spawn VEMFr_fnc_log;
if (isNull _cfg) then
{
//["fn_getSetting", 1, format["_cfg isNull. Resetting _cfg...."]] spawn VEMFr_fnc_log;
_cfg = configFile >> "CfgVemfReloaded";
call _build;
_cfg = _cfg >> _x;
//["fn_getSetting", 1, format["_cfg after second build = %1", _cfg]] spawn VEMFr_fnc_log;
};
//["fn_getSetting", 1, format["_cfg after appending _x = %1", _cfg]] spawn VEMFr_fnc_log;
2016-04-06 16:04:51 +00:00
call _check;
if not isNil"_v" then
{
_r pushBack _v
};
} forEach (_this select 1);
};
2016-04-10 15:25:24 +00:00
if (_this isEqualTypeArray [[]]) then
2016-04-06 16:04:51 +00:00
{
{
2016-04-13 20:28:31 +00:00
private ["_cfg"];
2016-04-10 15:25:24 +00:00
_cfg = configFile >> "CfgVemfReloaded" >> "CfgSettingsOverride" >> _x;
if (isNull _cfg) then
{
_cfg = configFile >> "CfgVemfReloaded" >> _x;
};
2016-04-06 16:04:51 +00:00
call _check;
_r pushBack _v;
} forEach (_this select 0);
};
};
_r