Jump to content
Sign in to follow this  
dmarkwick

Unable to execute IF loop, no idea why.

Recommended Posts

I'm testing a couple of methods for fire propagation, I got one method sort of working but it's pretty flaky. However, for this test I'm trying to maintain an array of all destroyed trees in the mission, and using that to check if the current tree is to be burned.

But, I cannot work out why the code inside the loop will not execute:

if (!(_objID in JTD_FireTrees)) then
 	{
   hint "JTD_FireTrees loop";
   nul = [_x] execVM "ForestFireTree.sqf";
   JTD_FireTrees = JTD_FireTrees + [_objID];
   sleep 5;
 	};

?

_x being the tree currently being tested. The loop works with the other method (testing for proximity of a custom object) and I'm not getting errors in the rpt. _objID definitely exists, 'cos I hint it just before the loop. JTD_FireTrees is initialised in the config like this:

JTD_FireTrees[] = {};

and yet the loop never executes. I never see the inner hint.

JTD_FireTrees is an array that all destroyed trees will go in, and objID is the ID number of the currently tested tree.

Share this post


Link to post
Share on other sites

Well, I got it to work by first ensuring that the array JTD_FireTrees was not empty. Apparently it doesn't like searching empty arrays :)

So I just make the array = [1,2] and it's happy :)

Share this post


Link to post
Share on other sites

yep disregard my post. if element in array does work of course.. :|

Share this post


Link to post
Share on other sites
Well, I got it to work by first ensuring that the array JTD_FireTrees was not empty. Apparently it doesn't like searching empty arrays :)

So I just make the array = [1,2] and it's happy :)

Oh Blimey, Good find DM - didn't know.

*Odan goes to doublecheck his missions*

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×