Jump to content
jakkob4682

having a problem using more than 1 than forEach loop.

Recommended Posts

_locations = [] call F_getTowns;// the function works as intended and set to debug returns an array of locations parsed from F_getLocations
_idx = 0;
{
	_loc = _locations select _idx;
	_pos = locationPosition _loc;
	_str = name _loc;


	_strongpoints = nearestLocations[_pos,["StrongpointArea"],750];
	_strongpoint = _strongpoints select _idx;
	_sPos = locationPosition _strongpoint;
	// do I need another forEach loop for _strongpoints inserted in this function?
	//here is where the function/scripts fails. As it is only creating one marker but there are 4 strongpoints being parsed
	_mrk = createMarker[_str,_sPos];
	_mrk setMarkerColor "ColorRed";
	_mrk setMarkerShape "Ellipse";
	_mrk setMarkerSize [50,50];

	_idx = _idx + 1;
}forEach _locations;

 

Edited by jakkob4682

Share this post


Link to post
Share on other sites

I guess you created some locations as strong points, because, if I'm right, there is no strong points in Arma3.

 

Anyway, in a forEach loop,  use the variable _forEachIndex  as current index. You don't need to increment anything.

Two markers can't have the same name. The second one is not created. If you don't need to use the marker name, just name them:  str random 1. There is very few chance to have two markers with the same name!

 

I don't know why you didn't go straight to your strong points:

 

_strongpoints = nearestLocations [[worldSize,worldSize],["StrongpointArea"],worldSize/1.4];

{ _strongpt = _strongpoints select _forEachIndex;

  _sPos = locationPosition _strongpt;

  _str = name _strongpt + str _forEachIndex;

  _mrk = createMarker[_str,_sPos];

  _mrk setMarkerColor "ColorRed";

  _mrk setMarkerShape "Ellipse";

  _mrk setMarkerSize [50,50];

}forEach _strongpoints;

 

 

Share this post


Link to post
Share on other sites
11 minutes ago, pierremgi said:

I guess you created some locations as strong points, because, if I'm right, there is no strong points in Arma3.

There are registered strongpoints on the CUP Takistan map.

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

×