Home   Help Search Login Register  

Author Topic: Unable to execute IF loop, dunno why  (Read 2681 times)

0 Members and 1 Guest are viewing this topic.

Offline DMarkwick

  • Contributing Member
  • **
  • I'm a llama!
Unable to execute IF loop, dunno why
« 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.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Unable to execute IF loop, dunno why
« Reply #1 on: 16 Aug 2009, 00:57:48 »
Weird.
Cant test the script outside of the addon, with an initialization of JTD_FireTrees = [];

Offline F2kSel

  • Members
  • *
Re: Unable to execute IF loop, dunno why
« Reply #2 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.

Offline DMarkwick

  • Contributing Member
  • **
  • I'm a llama!
Re: Unable to execute IF loop, dunno why
« Reply #3 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.

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: Unable to execute IF loop, dunno why
« Reply #4 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:
« Last Edit: 16 Aug 2009, 09:56:15 by h- »
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
Re: Unable to execute IF loop, dunno why
« Reply #5 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.
El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...