toggle trouble
I've been trying to make use of mist.flagFunc.units_in_polygon, but I've been running into trouble with the toggle variable.
The code I have in use is as follows;
mist.flagFunc.units_in_polygon{
units = {'[blue][plane]', '[-c]Turkey'},
zone = mist.getGroupPoints('testaircraft'),
flag = 50041,
stopflag = 90091,
interval = 5,
--toggle = true,
} The idea is that the flight plan for testaircraft takes it around a zone. No blue aircraft other than Turkish are to enter it, or else stuff happens. As the code is presented above, that works perfectly fine, and I couldn't be happier. Except I could.
The thing is, that if an aircraft leaves the zone, flag 50041 is still true, and so the next blue non-Turkish aircraft to enter the zone won't trigger the effect again. I need flag 50041 to revert to false again when the aircraft leave the zone. That's where the toggle variable comes into play. I think.
The documentation is a bit unclear about this. I get that it is supposed to do one of two things;
Make mist.flagFunc.units_in_polygon work as normal, but then turn flag back to false when no more units are in the zone (this is the effect I want, and what I assume it's supposed to do).
Make mist.flagFunc.units_in_polygon work inverted entirely: flag is specifically set to false when no units are in the zone (this seems a bit convoluted, but I can still use it, I'll just need to run mist.flagFunc.units_in_polygon once to turn the flag to true, then again with toggle to turn it back to false).
The problem I run into is as follows: The moment I uncomment the toggle line, the sim throws a scripting error at me the moment the script is loaded. The error is as follows;
[string "--MiST Mission Scripting Tools..."]:2064: attempt to call field 'getUserFlag' (a nil value)
stack traceback:
[C]: in function 'getUserFlag'
[string "--MiST Mission Scripting Tools..."]:2064: in function 'units_in_polygon'
[string "mist.flagFunc.units_in_polygon{..."]:1: in main chunk So my question is twofold:
What is the expected behaviour of the toggle variable? Is it supposed to behave like I described as option 1 or 2 above, or am I completely misunderstanding it?
Is this error caused by an issue with MiST and the toggle function, or am I doing something very wrong?
Any help on this issue would be much appreciated!
-Helios