Jump to content

Recommended Posts

I have been attempting to return a list of first and last names from the configs using the following;

_fn = (configfile >> "CfgWorlds" >> "GenericNames" >> "NATOMen" >> "FirstNames");
_ln = (configfile >> "CfgWorlds" >> "GenericNames" >> "NATOMen" >> "LastNames");

 

Sadly I haven't had any luck as the list of names aren't in an array.
I can return names if I already know the name which is... Infuriating!

getText (configfile >> "CfgWorlds" >> "GenericNames" >> "NATOMen" >> "FirstNames" >> "aaron_baf") // "Aaron" - What a surprise!!


Does anyone have a solution?

  • Like 1

Share this post


Link to post
Share on other sites

To get an array from a config you'd need to use the proper command.

 

getArray will return an array from the selected config entry, though not what you need in this case.

You just need to iterate over all cfg entries within the desired hierarchy.

 

Could look like this:

_fn = [];
_cfg = (configfile >> "CfgWorlds" >> "GenericNames" >> "NATOMen" >> "FirstNames");

for "_i" from 0 to ((count _cfg) - 1) do {	
	_fn pushBack getText (_cfg select _i);	
};
_fn

//returns ["Alfie","Benjamin","Callum"... etc.

Cheers

  • Like 1
  • Thanks 2

Share this post


Link to post
Share on other sites
_firstNames = configProperties[ configFile >> "CfgWorlds" >> "GenericNames" >> "NATOMen" >> "FirstNames", "isText( _x )", true ] apply{ getText( _x ) };

 

  • Like 3
  • Thanks 1

Share this post


Link to post
Share on other sites
4 hours ago, Larrow said:

_firstNames = configProperties[ configFile >> "CfgWorlds" >> "GenericNames" >> "NATOMen" >> "FirstNames", "isText( _x )", true ] apply{ getText( _x ) };

 

Well what do you know, this command even exists since 1.36...

 

Spoiler

Now I need to head into the cellar for further cargo cult programming rituals...

 

Cheers

  • Haha 3

Share this post


Link to post
Share on other sites

You gotta love Grump and Larrow (they should form a law firm:  "Grump and Larrow").  

 

Hey @Maff, I'm curious what your use case/need for the list of names is?

  • Like 1

Share this post


Link to post
Share on other sites

@johnnyboy

A friend of mine wanted a scripting solution to retrieve a list of names Spanish names from CUP Units to assign to civilian agents spawned in progress.

 

 

  • Like 3

Share this post


Link to post
Share on other sites
On 12/17/2019 at 7:53 AM, Grumpy Old Man said:

Well what do you know, this command even exists since 1.36

I always forget about it as well 😄 always use configClasses but always forget about this one.

  • Like 1

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

×