ACE3/addons/common/functions/fnc_getTurrets.sqf

53 lines
1.1 KiB
Plaintext
Raw Normal View History

/*
* Author: commy2
*
* Get all turret indicies of a vehicle.
*
* Argument:
* 0: Vehicle type (String)
*
* Return value:
* All turret index arrays of the vehicle. E.g: [[0], [0,0]] (Array)
*/
2015-01-13 19:56:02 +00:00
#include "script_component.hpp"
2015-05-14 22:12:40 +00:00
private ["_config", "_turrets", "_fnc_addTurret", "_varName"];
2015-05-14 18:06:06 +00:00
PARAMS_1(_type);
_varName = format ["ACE_CachedTurrets_%1", _type];
_turrets = + (uiNamespace getVariable _varName);
if (!isNil "_turrets") exitWith {_turrets};
_config = configFile >> "CfgVehicles" >> _type;
_turrets = [];
_fnc_addTurret = {
2015-05-14 18:06:06 +00:00
private ["_count", "_offset", "_index", "_path2", "_config2"];
2015-05-14 18:06:06 +00:00
PARAMS_2(_config,_path);
2015-05-14 18:06:06 +00:00
_config = _config >> "Turrets";
_count = count _config;
2015-05-14 18:06:06 +00:00
_offset = 0;
for "_index" from 0 to (_count - 1) do {
_path2 = _path + [_index - _offset];
_config2 = _config select _index;
2015-05-14 18:06:06 +00:00
if (isClass _config2) then {
_turrets pushBack _path2;
[_config2, _path2] call _fnc_addTurret;
} else {
_offset = _offset + 1;
};
};
};
[_config, []] call _fnc_addTurret;
uiNamespace setVariable [_varName, _turrets];
_turrets