Hello guys, sorry for not conforming to reporting standards, but this one is strictly code-related. Isn't this invalid code?
I believe it should be
FILTER(_loaded,!isNil "_x");
Did you encounter an actual issue or did you review the existing code?
Well under normal circumstances, I haven't encountered any issues. However, if you try something like this:
["ACE_Wheel", _vehicle, 10] call ace_cargo_fnc_removeCargoItem;
when there aren't 10 tyres in the cargo, which is pretty bad, I admit, you end up getting this:
2020/01/05, 14:42:27 Error in expression
_loaded = _loaded select {_x != nil};
true
};if (!_continue) exi>
2020/01/05, 14:42:27 Error position: <_x != nil};
true
};if (!_continue) exi>
2020/01/05, 14:42:27 Error Undefined variable in expression: _x
2020/01/05, 14:42:27 File z\ace\addons\cargo\functions\fnc_removeCargoItem.sqf..., line 56
I just happened to gaze at the code and saw this and thought it might have been a mistake, that's all. If it's intentionally made that way, my bad.
Only if you call this function is scheduled environment.
Try:
isNil {
["ACE_Wheel", _vehicle, 10] call ace_cargo_fnc_removeCargoItem;
};
instead.
Yes _x != nil is invalid. != will just return nil, always, even if _x is not nil.
@654wak654
_loaded select {nil} returns empty array
so before PR this would cause loss of loaded items
q setVariable ["ace_cargo_loaded", ["ACE_Wheel", "ACE_Wheel"]];
["ACE_Wheel", q, 1] call ace_cargo_fnc_removeCargoItem
q getVariable "ace_cargo_loaded" = []
Most helpful comment
_loaded select {nil}returns empty arrayso before PR this would cause loss of loaded items