ACE3/addons/common/functions/fnc_getTurrets.sqf

53 lines
1.1 KiB
Plaintext
Raw Normal View History

/*
* Author: commy2
2015-09-20 21:40:51 +00:00
* Get all turret indicies of a vehicle type.
*
2015-09-20 21:40:51 +00:00
* Arguments:
* 0: Vehicle type <STRING>
*
2015-09-20 21:40:51 +00:00
* Return Value:
* Turret Indecies <ARRAY>
*
2015-09-20 21:40:51 +00:00
* Public: Yes
*
* Note: It's advised to use allTurrets [_vehicle, true] instead whenever possible
*/
2015-01-13 19:56:02 +00:00
#include "script_component.hpp"
2015-09-20 21:40:51 +00:00
params ["_type"];
private _varName = format [QGVAR(CachedTurrets_%1), _type];
private _turrets = + (uiNamespace getVariable _varName);
if (!isNil "_turrets") exitWith {_turrets};
private _config = configFile >> "CfgVehicles" >> _type;
_turrets = [];
private _fnc_addTurret = {
2015-09-20 21:40:51 +00:00
params ["_config", "_path"];
2015-05-14 18:06:06 +00:00
_config = _config >> "Turrets";
2015-09-20 21:40:51 +00:00
private _offset = 0;
2015-09-20 21:40:51 +00:00
for "_index" from 0 to (count _config - 1) do {
private _path2 = _path + [_index - _offset];
private _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