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

Work out size of markers

Recommended Posts

OK need some Help/ Advice please

 

I am creating a marker around all my towns and i would like to populate them depending on Size of the marker , would this be the way to go ?

 

Not sure this is correct to get the size of the marker ?  

 

Thanks 

{
	private [ "_town", "_tempArray", "_sizeX", "_sizeY", "_name", "_zonename", "_foo", "_zoneCheck", "_zoneunit" ];

	_town = text _x;
    _tempArray = toArray _town;
	_tempArray = _tempArray - [ 32 ];
	_town = toString _tempArray;

    _sizeX = getNumber (configFile >> "CfgWorlds" >> worldName >> "Names" >> (text _x) >> "radiusA");
    _sizeY = getNumber (configFile >> "CfgWorlds" >> worldName >> "Names" >> (text _x) >> "radiusB");

	_name = format["mrk_%1", _town];
	_zonename  = format["Z_%1", _town];

    _foo = createmarker [_name, getPos _x];
    _foo setMarkerSize [_sizeX, _sizeY ];
    _foo setMarkerShape "ELLIPSE";
    _foo setMarkerBrush "SOLID";

 	if ((_sizeX) <= 150)
		then {

spawn stuff

			};

	if ((_sizeX) <= 250)
		then {
spawn stuff

			};


	if ((_sizeX) <= 350)
		then {


			};



	if ((_sizeX) <= 450)
		then {


			};

	if ((_sizeX) <= 550)
		then {

spawn stuff
			};

	if ((_sizeX) <= 650)
		then {

spawn stuff
			};


	if ((_sizeX) <= 750)
		then {

			};

	if ((_sizeX) <= 850)
		then {
spawn stuff
			};

    if ((_sizeX) > 850)
        then {
spawn stuff
            };

	sleep 0.2;

} forEach nearestLocations [getArray (configFile >> "CfgWorlds" >> worldName >> "centerPosition"), ["NameCityCapital","NameLocal","NameCity","NameVillage","Strategic","CityCenter","NameMarine","Hill","StrongpointArea"], 25000];



Share this post


Link to post
Share on other sites

You can get size of town simply by returning a list of locations and using the size command:

 

(code not tested)

_locations = [/*list of locations*/];
{
   _location = _x;
   _size = size _location;

   ...

   _marker setMarkerSize _size;

   // Do more stuff

} forEach _locations;

Hope that helps,

 

Bull

Share this post


Link to post
Share on other sites

Sorry should have make it a little clearer  :)  I have all the markers around the towns with the correct Sizes , its the next bit where i spawn depending on Size

 

i.e.....

 	if ((_sizeX) <= 150)
		then {

spawn stuff

			};

This is the bit I am having trouble with what is best approach 

Share this post


Link to post
Share on other sites

When the _sizeX is 100, all the spawn codes will run? Wouldn't it be better if only one of them ran?

So use switch..do..case structure:

switch (true) do {
  case (_sizeX <= 150): { spawn stuff };
  case (_sizeX <= 250): { spawn stuff };
  case (_sizeX <= 350): { spawn stuff };
  case (_sizeX <= 450): { spawn stuff };
 etc.
  case (_sizeX > 850): { spawn stuff };
};
  • Like 1

Share this post


Link to post
Share on other sites

 

When the _sizeX is 100, all the spawn codes will run? Wouldn't it be better if only one of them ran?

So use switch..do..case structure:

switch (true) do {
  case (_sizeX <= 150): { spawn stuff };
  case (_sizeX <= 250): { spawn stuff };
  case (_sizeX <= 350): { spawn stuff };
  case (_sizeX <= 450): { spawn stuff };
 etc.
  case (_sizeX > 850): { spawn stuff };
};

 

Wouldn't this still run the <=150 even though the marker is <=450???

 

Should it not be more like this?? (I think a simple 'between' command would be very helpful here..... between [_a,_b];  just thinking)

 

switch (true) do {
  case (_sizeX <= 150 && !(_sizeX >150)): { spawn stuff };
  case (_sizeX <= 250 && !(_sizeX >250)): { spawn stuff };
  case (_sizeX <= 350 && !(_sizeX >350)): { spawn stuff };
  case (_sizeX <= 450 && !(_sizeX >450)): { spawn stuff };
 etc.
  case (_sizeX > 850): { spawn stuff };
};

Share this post


Link to post
Share on other sites

 

Wouldn't this still run the <=150 even though the marker is <=450???

If the size is 100, the <=150 runs.

If it's 400, only the <=450 runs, because that's the first case that matches the condition.

case (_sizeX <= 150 && !(_sizeX >150)): { spawn stuff };

Isn't all numbers up to 150 smaller than 150? :)

Share this post


Link to post
Share on other sites

I'm overthinking it....

 

the <= does fix the issue with having to define the larger boundary of each condition.

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  

×