Jump to content
Sign in to follow this  
1para{god-father}

Help with Array and Marker

Recommended Posts

Trying to get this to work but for some reason not getting anything in the Array ?

I am trying to get a list of All markers that are "Blue" from my list of marker.


_ALL_markers = ["base1","base2","base3","base4"];
_notCaptured [];

{if ((getMarkerColor _x) != "ColorBlue" then {_notCaptured = _notCaptured + [_x]}} foreach _ALL_markers;

where am i going wrong ?

Share this post


Link to post
Share on other sites

You need to work on how you write, your syntax is probably what is going wrong. Here is what it looks like when written out a little better:

_ALL_markers = ["base1","base2","base3","base4"];
_notCaptured [];

{
if ((getMarkerColor _x) != "ColorBlue" then 
{
	_notCaptured = _notCaptured + [_x]
}

} foreach _ALL_markers;

You're missing a semi-colon, and you have a missing ")".

Edited by Jacmac

Share this post


Link to post
Share on other sites
You need to work on how you write, your syntax is probably what is going wrong. Here is what it looks like when written out a little better:

_ALL_markers = ["base1","base2","base3","base4"];
_notCaptured [];

{
if ((getMarkerColor _x) != "ColorBlue" then 
{
	_notCaptured = _notCaptured + [_x]
}

} foreach _ALL_markers;

You're missing a semi-colon, and you have a missing ")".

Agree you can read it better your way , however there is nothing missing looking at your code to my code, and it still does not work!?

any other suggestion on how to get it to work ?

Thanks

Share this post


Link to post
Share on other sites

Syntax error:

if ((getMarkerColor _x) != "ColorBlue" then 

Should be:

if ((getMarkerColor _x) != "ColorBlue") then 

Other than that, I wouldn't know.

EDIT: Whoopsie, Jacmac actually pointed this out already with the semicolon thingy. Oh well.

I should also point out that there are two semicolons missing: first after [_x] and the other after

the if(){} block.

Edited by Jukk

Share this post


Link to post
Share on other sites
Syntax error:

if ((getMarkerColor _x) != "ColorBlue" then 

Should be:

if ((getMarkerColor _x) != "ColorBlue") then 

Other than that, I wouldn't know.

EDIT: Whoopsie, Jacmac actually pointed this out already with the semicolon thingy. Oh well.

I should also point out that there are two semicolons missing: first after [_x] and the other after

the if(){} block.

Ahhh spotter the ( now !

Does it need the semicolons if they are withing the IF {} statement ?

Share this post


Link to post
Share on other sites

I am uncertain if it is really necessary but at least it's good practice. I am sure that if you had more than one statement inside the if-block, it would be mandatory.

Share this post


Link to post
Share on other sites

If you have more than one statement it's needed, but else it's not necessary. Still good practice to do it if you write the code out.

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  

×