OFPEC Forum

Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting General => Topic started by: DMarkwick on 15 Aug 2009, 23:32:28

Title: Unable to execute IF loop, dunno why
Post by: DMarkwick on 15 Aug 2009, 23:32:28
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: [Select]
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: [Select]
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.
Title: Re: Unable to execute IF loop, dunno why
Post by: Mandoble on 16 Aug 2009, 00:57:48
Weird.
Cant test the script outside of the addon, with an initialization of JTD_FireTrees = [];
Title: Re: Unable to execute IF loop, dunno why
Post by: F2kSel on 16 Aug 2009, 01:16:52
I don't have the addon or know how to edit config.

but placing JTD_FireTrees=[] in an init line and adding  _objID=2 to the script to give it a value to check it reaches the  inner hint.

If I change JTD_FireTrees=[3,6,2]  the inner hint does not show so I assume the script is fine.

It's either how it's initialised or the  compared items or incorrect in some way.
Title: Re: Unable to execute IF loop, dunno why
Post by: DMarkwick on 16 Aug 2009, 04:01:02
You're right F2kSel, if I initilise the array in the player's init field to [1,2], it all works. But if I initialise it in the config like:
Code: [Select]
JTD_FireTrees[] = {1,2};
it does not. Odd.
Title: Re: Unable to execute IF loop, dunno why
Post by: h- on 16 Aug 2009, 09:52:59
Have you tried putting this before the if statement?
Code: [Select]
JTD_FireTrees = getArray(configFile >> "JTD_FireTrees");
If you're already done this then it certainly is weird..  :dunno:
Title: Re: Unable to execute IF loop, dunno why
Post by: johnnyboy on 17 Aug 2009, 06:20:27
I had trouble calling a .sqf this way from another .sqf:

Code: [Select]
nul = [_x] execVM "ForestFireTree.sqf";
But when I dropped the "nul =" part it worked.  So this might work:

Code: [Select]
[_x] execVM "ForestFireTree.sqf";
This worked for me (not with your .sqf, but another one I'm working on).  Good luck.