Jump to content
Sign in to follow this  
tryteyker

Getting a string of town & village names

Recommended Posts

Hi,

so right now I'm trying to get a list of town & village names (in string format) for use in scripts, but I have no idea how to do this. Sadly, nearestLocations only returns something like this:

Location NameCity [XXXX, YYYY];

So that isn't an option. I'd like to avoid placing markers everywhere.

An idea I have going through my head would be incorporate a switch statement into a for loop to place markers and name them appropriately but the problem with this is that I have 0 idea what number equals what town / village so this may not work either. Right now I'm simply placing numbered markers everywhere via for loop.

If anybody wants to give it a shot here's the script (I'm actually just going to post the full script, because why not):

titleCut ["RANDOM TOWN WARS","BLACK IN",15];
_villages = nearestLocations [getmarkerpos "center",["NameVillage","NameCity","NameCityCapital"], 50000];
towns = [];
for "_i" from 0 to count _villages - 1 do {
sleep 0.1;
_town = _villages select _i;
_mkrname = format ["%1",_i];
_mkr = createMarker [_mkrname,getpos _town];
towns = towns + [_mkr];
};

randtown = (floor(random(count towns)));
switch (randtown) do {
case 0:
{ 
 _mk = towns select randtown;
 _mk setMarkerType "DESTROY";
 _mk setmarkershape "ICON";
};
case 1:
{
 _mk = towns select randtown;
 _mk setMarkerType "DESTROY";
 _mk setmarkershape "ICON";
};
case 2:
{ 
 _mk = towns select randtown;
 _mk setMarkerType "DESTROY";
 _mk setmarkershape "ICON";
};
case 3:
{ 
 _mk = towns select randtown;
 _mk setMarkerType "DESTROY";
 _mk setmarkershape "ICON";
};
case 4:
{ 
 _mk = towns select randtown;
 _mk setMarkerType "DESTROY";
 _mk setmarkershape "ICON";
};
case 5:
{ 
 _mk = towns select randtown;
 _mk setMarkerType "DESTROY";
 _mk setmarkershape "ICON";
};
case 6:
{ 
 _mk = towns select randtown;
 _mk setMarkerType "DESTROY";
 _mk setmarkershape "ICON";
};
case 7:
{ 
 _mk = towns select randtown;
 _mk setMarkerType "DESTROY";
 _mk setmarkershape "ICON";
};
case 8:
{ 
 _mk = towns select randtown;
 _mk setMarkerType "DESTROY";
 _mk setmarkershape "ICON";
};
case 9:
{ 
 _mk = towns select randtown;
 _mk setMarkerType "DESTROY";
 _mk setmarkershape "ICON";
};
case 10:
{ 
 _mk = towns select randtown;
 _mk setMarkerType "DESTROY";
 _mk setmarkershape "ICON";
};
 case 11:
{ 
 _mk = towns select randtown;
 _mk setMarkerType "DESTROY";
 _mk setmarkershape "ICON";
};
 case 12:
{ 
 _mk = towns select randtown;
 _mk setMarkerType "DESTROY";
 _mk setmarkershape "ICON";
};
 case 13:
{ 
 _mk = towns select randtown;
 _mk setMarkerType "DESTROY";
 _mk setmarkershape "ICON";
};
 case 14:
{ 
 _mk = towns select randtown;
 _mk setMarkerType "DESTROY";
 _mk setmarkershape "ICON";
};
 case 15:
{ 
 _mk = towns select randtown;
 _mk setMarkerType "DESTROY";
 _mk setmarkershape "ICON";
};
 case 16:
{ 
 _mk = towns select randtown;
 _mk setMarkerType "DESTROY";
 _mk setmarkershape "ICON";
};
 case 17:
{ 
 _mk = towns select randtown;
 _mk setMarkerType "DESTROY";
 _mk setmarkershape "ICON";
};
 case 18:
{ 
 _mk = towns select randtown;
 _mk setMarkerType "DESTROY";
 _mk setmarkershape "ICON";
};
 case 19:
{ 
 _mk = towns select randtown;
 _mk setMarkerType "DESTROY";
 _mk setmarkershape "ICON";
};
 case 20:
{ 
 _mk = towns select randtown;
 _mk setMarkerType "DESTROY";
 _mk setmarkershape "ICON";
};
 case 21:
{ 
 _mk = towns select randtown;
 _mk setMarkerType "DESTROY";
 _mk setmarkershape "ICON";
};
 case 22:
{ 
 _mk = towns select randtown;
 _mk setMarkerType "DESTROY";
 _mk setmarkershape "ICON";
};
 case 23:
{ 
 _mk = towns select randtown;
 _mk setMarkerType "DESTROY";
 _mk setmarkershape "ICON";
};
 case 24:
{ 
 _mk = towns select randtown;
 _mk setMarkerType "DESTROY";
 _mk setmarkershape "ICON";
};
 case 25:
{ 
 _mk = towns select randtown;
 _mk setMarkerType "DESTROY";
 _mk setmarkershape "ICON";
};
 case 26:
{ 
 _mk = towns select randtown;
 _mk setMarkerType "DESTROY";
 _mk setmarkershape "ICON";
};
 case 27:
{ 
 _mk = towns select randtown;
 _mk setMarkerType "DESTROY";
 _mk setmarkershape "ICON";
};
 case 28:
{ 
 _mk = towns select randtown;
 _mk setMarkerType "DESTROY";
 _mk setmarkershape "ICON";
};
 case 29:
{ 
 _mk = towns select randtown;
 _mk setMarkerType "DESTROY";
 _mk setmarkershape "ICON";
};
};
ah1z2 engineon true;
_pos = towns select randtown;
_modpos2 = [(getmarkerpos _pos select 0) - 150, (getmarkerpos _pos select 1) - 150, 0];
_modpos = [(getmarkerpos _pos select 0) + 80, (getmarkerpos _pos select 1) + 80, 0];
_modpos3 = [(getmarkerpos _pos select 0) + 350, (getmarkerpos _pos select 1) + 350, 0];
_opgrp1 = [_modpos2, EAST, 10] call bis_fnc_spawngroup;
sleep 0.5;
_opgrp2 = [_modpos2, EAST, 10] call bis_fnc_spawngroup;
sleep 0.5;
_blugrp1 = [_modpos, WEST, 15] call bis_fnc_spawngroup;
sleep 0.5;
_blugrp2 = [_modpos, WEST, 15] call bis_fnc_spawngroup;
sleep 0.5;
_opvehgrp1 = [_modpos3, EAST, 

_bluleader1 = leader _blugrp1;
_bluleader2 = leader _blugrp2;
_opleader1 = leader _opgrp1;
_opleader2 = leader _opgrp2;


_opgrp1 setBehaviour "COMBAT";
{
_x domove (getpos _bluleader1);
} foreach units _opgrp1;
_opgrp2 setBehaviour "COMBAT";
{
_x domove (getpos _bluleader2);
} foreach units _opgrp2;
_blugrp1 setBehaviour "COMBAT";
{
_x domove (getpos _opleader1);
} foreach units _blugrp1;
_blugrp2 setBehaviour "COMBAT";
{
_x doMove (getpos _opleader2);
} foreach units _blugrp2;

// hint format ["Get to %1, enemies have been seen there.",str(_pos)];

You'll notice the commented out hint. This returns what I posted above.

Share this post


Link to post
Share on other sites

Doesn't seem to work in conjunction with nearestLocations or a marker position. That's really the only thing I can base that off off unless I'm blind.

Share this post


Link to post
Share on other sites

Hoz has a find closest town function, in which the name is output also. I use a modified version. Maybe this could be of use?

Otherwise, here's some food for thought from the function:

_cfgTowns=(configFile >> "cfgWorlds" >> WorldName >> "Names");
for "_i" from 0 to ((Count _cfgTowns)-1) do
{
  _cfgPath = _cfgTowns Select _i;
  _typecity =  getText (_cfgPath >> "type");
  if ((_typecity == "NAMECITY") || (_typecity == "NAMEVILLAGE") || (_typecity == "NAMECITYCAPITAL") || (_typecity == "NAMELOCAL")) then 
  {
     _towns Set [_i,[getText (_cfgPath >> "name"),getArray (_cfgPath >> "position"), _typecity]];			
  };
};

Share this post


Link to post
Share on other sites
Doesn't seem to work in conjunction with nearestLocations or a marker position. That's really the only thing I can base that off off unless I'm blind.

Perhpas I do not understood right, what is yours goal, but such code in player's init field:

nul = [] spawn {_Villages = nearestLocations [position player, ["NameVillage"], 5000]; {diag_log (text _x)} foreach _villages};

will return in RPT output like this:

"Novy Sobor"
"Vyshnoye"
"Kabanino"
"Rogovo"
"Guglovo"
"Pogorevka"
"Pulkovo"
"Mogilevka"
"Grishino"
"Nadezhdino"
"Shakhovka"
"Pustoshka"
"Kozlovka"
"Polana"
"Drozhino"
"Staroye"
"Sosnovka"
"Prigorodki"
"Pusta"
"Dubrovka"
"Lopatino"
"Myshkino"
"Dolina"
"Gvozdno"
"Bor"

Share this post


Link to post
Share on other sites

I tested it like this:

_towns = [getmarkerpos _pos,["NameCity","NameVillage","NameCityCapital"],1];
_obj = text _towns select 0;

The thing is it's an array still since _towns select 0 simply returns Location NameCity [XXXX, YYYY] for me.

So I used str, but it didn't help one single bit, still returning the above.

Share this post


Link to post
Share on other sites

And if we will add ()?

_towns = [getmarkerpos _pos,["NameCity","NameVillage","NameCityCapital"],1];
_obj = text [color="#FF0000"]([/color]_towns select 0[color="#FF0000"])[/color];

That code in init field:

nul = [] spawn {_villages = nearestLocations [position player, ["NameVillage"], 5000]; diag_log (text (_villages select 0))};

gives me "Novy Sobor". Without braces - only error log.

Share this post


Link to post
Share on other sites

Thanks, putting parenthesis did the trick. DAMN YOU PARENTHESIS :(

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  

×