mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
ACE_Settings: function for updating settings from modules
This commit is contained in:
parent
66045b8d51
commit
92d21af8c6
@ -100,8 +100,7 @@ PREP(player);
|
||||
PREP(playerSide);
|
||||
PREP(progressBar);
|
||||
PREP(queueAnimation);
|
||||
PREP(readBooleanParameterFromModule);
|
||||
PREP(readNumericParameterFromModule);
|
||||
PREP(readSettingFromModule);
|
||||
PREP(removeActionEventHandler);
|
||||
PREP(removeActionMenuEventHandler);
|
||||
PREP(removeCameraEventHandler);
|
||||
|
@ -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);
|
@ -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);
|
27
addons/common/functions/fnc_readSettingFromModule.sqf
Normal file
27
addons/common/functions/fnc_readSettingFromModule.sqf
Normal 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);
|
Loading…
Reference in New Issue
Block a user