2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
2015-09-20 22:28:25 +00:00
|
|
|
/*
|
|
|
|
* Author: Glowbal
|
|
|
|
* Grabs a variable. If variable has not been set, attempts to use default defined value
|
2015-01-16 23:21:47 +00:00
|
|
|
*
|
2015-09-20 22:28:25 +00:00
|
|
|
* Arguments:
|
|
|
|
* 0: unit <OBJECT>
|
|
|
|
* 1: Variable Name <STRING>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* Value of variable or default value, if the variable is undefined <ANY>
|
|
|
|
*
|
2017-06-08 13:31:51 +00:00
|
|
|
* Example:
|
|
|
|
* [bob, "var"] call ace_common_fnc_getDefinedVariable
|
|
|
|
*
|
2015-09-20 22:28:25 +00:00
|
|
|
* Public: No
|
2015-01-16 23:21:47 +00:00
|
|
|
*/
|
|
|
|
|
2015-09-20 22:28:25 +00:00
|
|
|
params ["_unit", "_variable", "_defaultValue"];
|
2015-01-16 23:21:47 +00:00
|
|
|
|
2015-12-12 15:48:54 +00:00
|
|
|
private _value = _unit getVariable _variable;
|
2015-01-16 23:21:47 +00:00
|
|
|
|
2015-09-20 22:28:25 +00:00
|
|
|
if (isNil "_value") then {
|
|
|
|
if (!isNil "_defaultValue") then {
|
|
|
|
_value = _defaultValue;
|
2015-01-18 19:09:19 +00:00
|
|
|
} else {
|
2015-12-12 16:26:47 +00:00
|
|
|
private _definedVariable = _variable call FUNC(getDefinedVariableInfo);
|
2015-09-20 22:28:25 +00:00
|
|
|
|
2015-01-18 19:09:19 +00:00
|
|
|
if (count _definedVariable > 1) then {
|
|
|
|
_value = _definedVariable select 1;
|
|
|
|
};
|
|
|
|
};
|
2015-09-20 22:28:25 +00:00
|
|
|
|
|
|
|
if (isNil "_value") then {
|
2015-01-18 19:09:19 +00:00
|
|
|
_value = 0;
|
|
|
|
};
|
2015-01-16 23:21:47 +00:00
|
|
|
};
|
2015-09-20 22:28:25 +00:00
|
|
|
|
|
|
|
_value
|