Results 1 to 5 of 5

Thread: Unable to execute IF loop, no idea why.

  1. #1

    Unable to execute IF loop, no idea why.

    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:

    Code:
    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:
    Code:
    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.
    Fire And Smoke for ArmA2: JTD_FireAndSmoke v0.2

    For better future effects addons, please vote for this ticket.

  2. #2
    You cannot use in that way for a if query.
    http://community.bistudio.com/wiki/in_Array

    you need to use this

    Code:
    _found = false;
    
    {
     if (_objID == _x) then { _found = true; };
    } forEach JTD_FireTrees;
    
    if (!_found) then 
    {
     ...

  3. #3
    Captain DMarkwick's Avatar
    Join Date
    Mar 19 2006
    Location
    Lincolnshire, UK.
    Posts
    6,581
    Author of the Thread
    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

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

  5. #5
    Quote Originally Posted by DMarkwick View Post
    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*

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •