ACE3/addons/common/functions/fnc_defineVariable.sqf

38 lines
1.1 KiB
Plaintext
Raw Normal View History

#include "script_component.hpp"
2015-09-18 13:40:51 +00:00
/*
* Author: Glowbal
* Define a variable for the ACE variable framework
2015-01-16 23:21:47 +00:00
*
2015-09-18 13:40:51 +00:00
* Arguments:
* 0: Name <STRING>
* 1: defaultValue <ANY>
* 2: publicFlag <BOOL>
* 3: category <STRING>
* 4: type (default: 0) <NUMBER>
* 5: persistentFlag (default: false) <BOOL>
*
* Return Value:
* None
*
* Example:
* ["bob", 1, true, "category", 1, true] call ace_common_fnc_defineVariable
*
2015-09-18 13:40:51 +00:00
* Public: Yes
2015-01-16 23:21:47 +00:00
*/
2015-09-18 13:40:51 +00:00
params ["_name", "_value", "_defaultGlobal", "_category", ["_code", 0], ["_persistent", false]];
2015-05-14 18:06:06 +00:00
2015-09-18 13:40:51 +00:00
if (isNil "_defaultGlobal") exitWith {};
2015-01-16 23:21:47 +00:00
if (!(_name isEqualType "")) exitwith {
2015-09-18 14:00:58 +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
};
2015-09-18 13:40:51 +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
};
2015-09-18 13:40:51 +00:00
GVAR(OBJECT_VARIABLES_STORAGE) pushBack [_name, _value, _defaultGlobal, _category, _code, _persistent];
2015-01-16 23:21:47 +00:00
2015-09-18 13:40:51 +00:00
missionNamespace setVariable [QGVAR(OBJECT_VARIABLES_STORAGE_) + _name, [_name, _value, _defaultGlobal, _category, _code, _persistent]];