dmarkwick 261 Posted August 15, 2009 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
.kju 3245 Posted August 16, 2009 You cannot use in that way for a if query. http://community.bistudio.com/wiki/in_Array you need to use this _found = false; { if (_objID == _x) then { _found = true; }; } forEach JTD_FireTrees; if (!_found) then { ... Share this post Link to post Share on other sites
dmarkwick 261 Posted August 16, 2009 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
.kju 3245 Posted August 16, 2009 yep disregard my post. if element in array does work of course.. :| Share this post Link to post Share on other sites
[asa]oden 0 Posted August 17, 2009 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