ACE3/addons/common/functions/fnc_readSettingFromModule.sqf

39 lines
1.4 KiB
Plaintext
Raw Normal View History

/*
2015-03-24 04:18:00 +00:00
* Author: esteldunedain
* Reads a setting value from a module, set it and force it. Logs if the setting is missing from the module.
* Must be called on the server, effect is global.
*
* Arguments:
2015-09-18 23:50:17 +00:00
* 0: Module <OBJECT>
* 1: ACE_Parameter name <STRING>
* 2: Module parameter name <STRING>
*
* Return Value:
* None
2015-09-18 23:50:17 +00:00
*
* Public: No
*/
#include "script_component.hpp"
if !(isServer) exitWith {};
2015-09-18 23:50:17 +00:00
params ["_logic", "_settingName", "_moduleVariable"];
// Check if the parameter is defined in the module
if (isNil {_logic getVariable _moduleVariable}) exitWith {
ACE_LOGWARNING_2("Warning in %1 module: %2 setting is missing. Probably an obsolete version of the module is used in the mission.",typeOf _logic,_moduleVariable);
};
2016-02-29 20:06:14 +00:00
private _value = _logic getVariable _moduleVariable;
2016-02-29 22:34:51 +00:00
if (_value isEqualTo -1) then {
2016-02-29 20:06:14 +00:00
//3den missions will save modules with value = 0 as -1
//If the setting has a "values" array, we should be able to assume that -1 is not a valid number as it would not be a valid index for the array
if (isArray (configFile >> "ACE_Settings" >> _settingName >> "values")) then {
2016-02-29 22:34:51 +00:00
ACE_LOGWARNING_2("Module For Setting [%1] is saved as (-1), switching to (0) - missionVersion [%2]",_settingName,missionVersion);
2016-02-29 20:06:14 +00:00
_value = 0;
};
};
// Set the setting globally and force it
2016-02-29 20:06:14 +00:00
[_settingName, _value, true, true] call FUNC(setSetting);