ACE3/addons/common/functions/fnc_defineVariable.sqf

40 lines
1.2 KiB
Plaintext
Raw Normal View History

2015-01-16 23:21:47 +00:00
/**
* fn_defineVariable.sqf
* @Descr: Define a variable for the ACE variable framework
* @Author: Glowbal
*
* @Arguments: [name STRING, defaultValue ANY, publicFlag BOOL, category STRING, type NUMBER, persistentFlag BOOL]
* @Return:
* @PublicAPI: true
*/
#include "script_component.hpp"
private ["_name","_value","_defaultGlobal","_catagory","_code","_persistent"];
_name = _this select 0;
_value = _this select 1;
_defaultGlobal = _this select 2;
_catagory = _this select 3;
_code = 0;
_persistent = false;
if (count _this < 3) exitwith {};
if (count _this > 4) then {
2015-01-18 19:09:19 +00:00
_code = _this select 4;
if (count _this > 5) then {
_persistent = _this select 5;
};
2015-01-16 23:21:47 +00:00
};
if (typeName _name != typeName "") exitwith {
2015-01-18 19:09:19 +00:00
[format["Tried to the deinfe a variable with an invalid name: %1 Arguments: %2", _name, _this]] call FUNC(debug);
2015-01-16 23:21:47 +00:00
};
if (isnil QGVAR(OBJECT_VARIABLES_STORAGE)) then {
2015-01-18 19:09:19 +00:00
GVAR(OBJECT_VARIABLES_STORAGE) = [];
2015-01-16 23:21:47 +00:00
};
GVAR(OBJECT_VARIABLES_STORAGE) pushback [_name,_value,_defaultGlobal,_catagory,_code, _persistent];
2015-01-17 11:40:06 +00:00
missionNamespace setvariable [QGVAR(OBJECT_VARIABLES_STORAGE_) + _name, [_name,_value,_defaultGlobal,_catagory,_code, _persistent]];
2015-01-16 23:21:47 +00:00