ACE_Settings: function for updating settings from modules

This commit is contained in:
Nicolás Badano 2015-02-03 02:52:07 -03:00
parent 66045b8d51
commit 92d21af8c6
4 changed files with 28 additions and 64 deletions

View File

@ -100,8 +100,7 @@ PREP(player);
PREP(playerSide);
PREP(progressBar);
PREP(queueAnimation);
PREP(readBooleanParameterFromModule);
PREP(readNumericParameterFromModule);
PREP(readSettingFromModule);
PREP(removeActionEventHandler);
PREP(removeActionMenuEventHandler);
PREP(removeCameraEventHandler);

View File

@ -1,28 +0,0 @@
/*
* Author: CAA-Picard
*
* Reads a boolean value from a module, sets de ACE_Parameter. Logs if parameters are missing in the module.
*
* Arguments:
* 0: Module (Object)
* 1: ACE_Parameter name (string)
* 2: Module parameter name (string)
*
* Return Value:
* None
*/
#include "script_component.hpp"
private ["_logic", "_parameterName", "_moduleParameterName"];
_logic = _this select 0;
_parameterName = _this select 1;
_moduleParameterName = _this select 2;
// Check if the parameter is defined in the module
if (isNil {_logic getVariable _moduleParameterName}) exitWith {
diag_log text format["[ACE]: Warning in %1 module: %2 parameter is missing. Probably an obsolete version of the module is used in the mission.", typeOf _logic, _moduleParameterName];
};
// Set the parameter
[_parameterName , if (_logic getVariable _moduleParameterName) then {1} else {0}] call FUNC(setParameter);

View File

@ -1,34 +0,0 @@
/*
* Author: CAA-Picard
*
* Reads a numeric value from a module, sets de ACE_Parameter. Logs if parameters are missing in the module.
*
* Arguments:
* 0: Module (Object)
* 1: ACE_Parameter name (string)
* 2: Module parameter name (string)
*
* Return Value:
* None
*/
#include "script_component.hpp"
private ["_logic", "_parameterName", "_moduleParameterName", "_value"];
_logic = _this select 0;
_parameterName = _this select 1;
_moduleParameterName = _this select 2;
// Check if the parameter is defined in the module
if (isNil {_logic getVariable _moduleParameterName}) exitWith {
diag_log text format["[ACE]: Warning in %1 module: %2 parameter is missing. Probably an obsolete version of the module is used in the mission.", typeOf _logic, _moduleParameterName]
};
// Check if the value is defined as string for backward compatibility
_value = _logic getVariable _moduleParameterName;
if (typeName _value == "STRING") then {
_value = parseNumber _value;
};
// Set the parameter
[_parameterName, _value] call FUNC(setParameter);

View File

@ -0,0 +1,27 @@
/*
* Author: CAA-Picard
*
* 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:
* 0: Module (Object)
* 1: ACE_Parameter name (string)
* 2: Module parameter name (string)
*
* Return Value:
* None
*/
#include "script_component.hpp"
if !(isServer) exitWith {};
EXPLODE_3_PVT(_this,_logic,_settingName,_moduleVariable);
// Check if the parameter is defined in the module
if (isNil {_logic getVariable _moduleVariable}) exitWith {
diag_log text format["[ACE]: Warning in %1 module: %2 setting is missing. Probably an obsolete version of the module is used in the mission.", typeOf _logic, _moduleVariable];
};
// Set the setting globally and force it
[_settingName, _logic getVariable _moduleVariable, true, true] call FUNC(setSetting);