ACE3/addons/inventory/XEH_preStart.sqf
Dedmen Miller 21fd4e5d16 Inventory - Cache inventory postInit config lookups (#6803)
* Cache inventory postInit config lookups

* Safety

* fix

* More better

* ugh

* add parenthesii (not trolling)

these are actually needed
```
Error in expression <_inventory_Grenades_ItemList", []];
if (!ace_inventory_Grenades_ItemList isEqual>
  Error position: <!ace_inventory_Grenades_ItemList isEqual>
  Error !: Type Array, expected Bool
```

* Add space
2019-02-17 11:41:48 -06:00

58 lines
2.0 KiB
Plaintext

#include "script_component.hpp"
#include "XEH_PREP.hpp"
//item cache, see XEH_postInit.sqf
private _allItems = ("getNumber (_x >> 'scope') > 0" configClasses (configFile >> "CfgWeapons"));
_allItems append ("getNumber (_x >> 'scope') > 0" configClasses (configFile >> "CfgGlasses"));
_allItems append ("getNumber (_x >> 'scope') == 2" configClasses (configFile >> "CfgMagazines"));
_allItems append ("getNumber (_x >> 'scope') > 0 && {getNumber (_x >> 'isBackpack') == 1}" configClasses (configFile >> "CfgVehicles"));
uiNamespace setVariable [QGVAR(ItemKeyCache), _allItems apply {
private _displayName = getText (_x >> "displayName");
private _picture = getText (_x >> "picture");
// list box seems to delete the leading backslash
if (_picture select [0,1] == "\") then {
_picture = _picture select [1];
};
[format ["%1:%2", _displayName, _picture], _x];
}];
// generate list of grenades
private _grenades_ItemList = [];
{
_grenades_ItemList append getArray (configFile >> "CfgWeapons" >> "Throw" >> _x >> "magazines");
} forEach getArray (configFile >> "CfgWeapons" >> "Throw" >> "muzzles");
// make list case insensitive
_grenades_ItemList = _grenades_ItemList apply {toLower _x};
// filter duplicates
_grenades_ItemList = _grenades_ItemList arrayIntersect _grenades_ItemList;
uiNamespace setVariable [QGVAR(Grenades_ItemList), _grenades_ItemList];
// generate list of medical items
private _medical_ItemList = [];
{
_medical_ItemList append getArray (_x >> "items");
} forEach (
("true" configClasses (configFile >> QEGVAR(Medical,Actions) >> "Basic")) +
("true" configClasses (configFile >> QEGVAR(Medical,Actions) >> "Advanced"))
);
// remove all numbers from list
_medical_ItemList = _medical_ItemList select {_x isEqualType ""};
// make list case insensitive
_medical_ItemList = _medical_ItemList apply {toLower _x};
// filter duplicates
_medical_ItemList = _medical_ItemList arrayIntersect _medical_ItemList;
uiNamespace setVariable [QGVAR(Medical_ItemList), _medical_ItemList];