ACE3/addons/common/functions/fnc_setDefinedVariable.sqf

31 lines
791 B
Plaintext
Raw Normal View History

2015-01-16 23:21:47 +00:00
/**
* fn_setVariable.sqf
* @Descr: Setvariable value
* @Author: Glowbal
*
* @Arguments: [unit OBJECT, variableName STRING, value ANY]
* @Return: void
* @PublicAPI: true
*/
#include "script_component.hpp"
private ["_unit","_variable","_value","_update","_global","_definedVariable","_defaultGlobal","_currentValue"];
_unit = _this select 0;
_variable = _this select 1;
_value = _this select 2;
_global = false;
if (count _this > 3) then {
2015-01-18 19:09:19 +00:00
_global = _this select 3;
2015-01-16 23:21:47 +00:00
} else {
2015-01-18 19:09:19 +00:00
_definedVariable = ([_variable] call FUNC(getDefinedVariableInfo));
if (count _definedVariable > 2) then {
_global = _definedVariable select 2;
};
2015-01-16 23:21:47 +00:00
};
if (!isNil "_value") exitwith {
2015-01-18 19:09:19 +00:00
_unit setvariable [_variable, _value, _global];
2015-01-16 23:21:47 +00:00
};
_unit setvariable [_variable, nil, _global];