fix script error when calling undefined events #378
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
After #375 we copy the arrays from the event namespace. This leads to a typical SQF facepalm inducing issue...
["undefined", 1] call CBA_fnc_localEvent
If the variable on the namespace was undefined, it would previously do:
CODE forEach (LOCATION getVariable STRING)
CODE forEach nil
nil
Since we are now using the
+
operator to copy the array, it goes:CODE forEach +(LOCATION getVariable STRING)
CODE forEach +nil
CODE forEach nil*
->ERROR
nil*
is a special nil tagged as number instead of the "neutral"nil
from thegetVariable
operator. This is probably because+
is expected to return . The default syntax for plus is obviously for adding numbers and that's what the internals assume whennil
is used as argument.forEach
expects an array on the right side. In unscheduled environment, the command will fail silently for the "neutral nil", but for the "number type nil" (nil*), the input will be detected as being the wrong type. Therefore it reports:Error foreach: Type Number, [...], expected Array
I'll call these concepts "number flavoured" and "neutral flavoured" nil-types from now on. Thanks.
param
saves the day again.