Jump to content
Sign in to follow this  
Kotlx

Array find issue

Recommended Posts

ooookayy Im having trouble understanding why this isn't working ..

a = objectList;

b = a select 0;

c = b select 0;

d = c find guy1;

where objectList is a global array that holds a bunch of different objects. These objects are suppose to be removed from this array as they are interacted with. In this instance, I have 2 objects (both AI)

objectList = [[[guy1]],[[guy2]]];

The problem is, when I interact with the object, it fails to be removed. The object can't be found in the array. d returns -1.

Here's my confusion, and Im sure it has something to do with global arrays (though I cant modify it if I cant find the item in the index).

When I manually delcare the array:

a = [[[guy1]],[[guy2]]];

b = a select 0;

c = b select 0;

d = c find guy1;

d returns the correct index. what the hell am I doing wrong? ._.

 

When I manually declare, the debug console output shows a as this

a

[[[<NULL-object>]],[[<NULL-object>]]]

despite declaring it

 

 

edit:

 

I worked around this by setting the object's vehvarname in the array instead of the actual object. This allowed me to access the value and remove it at any point in the multidimensional array.

Share this post


Link to post
Share on other sites
{  

   if (isNull _x) then {

	 objectlist deleteAt _forEachIndex;    

 	}; 
} forEach objectlist;

 

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  

×