Fixed nilCheck, changed moduleAddSpareParts to use new parseList

This commit is contained in:
jonpas 2015-09-05 20:51:48 +02:00
parent 8fc061bfd6
commit 06baa5e4d3
2 changed files with 10 additions and 26 deletions

View File

@ -46,7 +46,7 @@ if (_checkNil) then {
_nilCheckedList = []; _nilCheckedList = [];
{ {
if !(isNil _x) then { if !(isNil _x) then {
_nilCheckedList pushBack _x; _nilCheckedList pushBack (missionNamespace getVariable _x);
}; };
nil nil
} count _list; } count _list;

View File

@ -11,51 +11,35 @@
* None * None
* *
* Example: * Example:
* function = "ace_repair_fnc_moduleAssignRepairVehicle" * function = "ace_repair_fnc_moduleAddSpareParts"
* *
* Public: No * Public: No
*/ */
#define DEBUG_MODE_FULL
#include "script_component.hpp" #include "script_component.hpp"
params ["_logic"]; params ["_logic"];
if (!isNull _logic) then { if (!isNull _logic) then {
private ["_list", "_part", "_amount", "_nilCheckPassedList"]; private ["_list", "_part", "_amount"];
// Module settings
_list = _logic getVariable ["List", ""]; _list = _logic getVariable ["List", ""];
_part = _logic getVariable ["Part", 0]; _part = _logic getVariable ["Part", 0];
_amount = _logic getVariable ["Amount", 1]; _amount = _logic getVariable ["Amount", 1];
// Parse list // Parse list
_nilCheckPassedList = ""; _list = [_list, true, true] call EFUNC(common,parseList);
{
_x = [_x] call EFUNC(common,stringRemoveWhiteSpace);
if !(isnil _x) then {
if (_nilCheckPassedList == "") then {
_nilCheckPassedList = _x;
} else {
_nilCheckPassedList = _nilCheckPassedList + "," + _x;
};
};
} forEach ([_list, ","] call BIS_fnc_splitString);
_list = "[" + _nilCheckPassedList + "]";
_list = [] call compile _list;
// Add synchronized objects to list // Add synchronized objects to list
{ {
_list pushBack _x; _list pushBack _x;
} forEach (synchronizedObjects _logic); nil
} count (synchronizedObjects _logic);
if (_list isEqualTo []) exitWith {}; if (_list isEqualTo []) exitWith {};
TRACE_3("module info parsed",_list,_part,_amount); TRACE_3("Module info parsed",_list,_part,_amount);
// Add spare parts // Add spare parts
{ {
if (!isNil "_x" && {typeName _x == typeName objNull}) then {
[_x, _amount, _part, true] call FUNC(addSpareParts); [_x, _amount, _part, true] call FUNC(addSpareParts);
} count _list;
}; };
} forEach _list;
};
true