ACE3/addons/arsenal/functions/fnc_addDefaultLoadout.sqf
Ozan Eğitmen db6a40f91d Arsenal - Add Default Loadouts API (#6558)
* Add addDefaultLoadout function

* Initialize defaultLoadoutsList by default

* Close params bracket

* Revert "Initialize defaultLoadoutsList by default"

This reverts commit a53d21046e.

* Add isNil check

* Remove tab

* Overwrite loadout if it exists

* Fix file name typo

* Use findIf and copy array

* Add override note to header

* Make btnImport use new function instead of duplicating code

* Use GVAR

* Use findIf

* Fix spacing

* Add documentation

* Improve documentation
2018-09-17 13:22:04 -05:00

32 lines
800 B
Plaintext

#include "script_component.hpp"
/*
* Author: 654wak654
* Adds a loadout to the "Default Loadouts" list.
* If a loadout with the same name exists, it is overwritten.
*
* Arguments:
* 0: Name of loadout <STRING>
* 1: getUnitLoadout array <ARRAY>
*
* Return Value:
* None
*
* Example:
* ["Squad Leader", getUnitLoadout sql1] call ace_arsenal_fnc_addDefaultLoadout
*
* Public: Yes
*/
params [["_name", "", [""]], ["_loadout", [], [[]], 10]];
if (isNil QGVAR(defaultLoadoutsList)) then {
GVAR(defaultLoadoutsList) = [];
};
private _loadoutIndex = (+(GVAR(defaultLoadoutsList))) findIf {(_x select 0) == _name};
if (_loadoutIndex == -1) then {
GVAR(defaultLoadoutsList) pushBack [_name, _loadout];
} else {
GVAR(defaultLoadoutsList) set [_loadoutIndex, [_name, _loadout]];
};