Maritime Weather+

[New Feature] Maritime Weather+ 6

The uncertainty to me is, do I need brackets around the conditional? The existing "not ... ==" failed, unbracketed. I don't understand why exactly, it's poor form perhaps but shouldn't it evaluate to same as the ~= form?

My guess is it failed cuz 'pPlot:GetFeatureType()' immediately following an 'if' of 'if not', somehow evaluates to "true"; maybe cuz it returns a non-nil value? If so original code is basically checking if false == -1, and never triggers correctly.

So for 'if pPlot:GetFeatureType() ~= FeatureTypes.NO_FEATURE' we might get another problem, as it might evaluate this as 'if true ~= -1' and misfire as well?

to be safe I'd change the line to

Code:
if (pPlot:GetFeatureType() ~= FeatureTypes.NO_FEATURE) then return false end
 
~= is always to be preferred to "not =="
Without brackets it evaluates "not pPlot:GetFeatureType()" that gives a boolean then you compare with a number (-1), so it gives error.
You don't need brackets in your solution:
Code:
if pPlot:GetFeatureType() ~= FeatureTypes.NO_FEATURE then return false end
But you could just simply type:
Code:
if pPlot:GetFeatureType() > -1 then return false end
Same result given -1 is the lowest value.
 
Back
Top Bottom