Jump to content
anfo

Array conversion please

Recommended Posts

Hi all

 

May borrow someone's grey matter to determine how to create an array from a particular command?

 

The command is:

{_x enablesimulation true} foreach units group en_1;

where en_1 is a single group enabled to move upon a fired trigger. However I'm sure there is a more efficient way (an array) to make many groups move instead of copying the same code over and over for each group?

 

Many thanks

 

Anfo

Share this post


Link to post
Share on other sites

You can join all groups to an single array.


_groups = [en_1,en_2,en_3,en_4];
{{_x enableSimulation true} forEach (units _x)} forEach _groups;

Share this post


Link to post
Share on other sites

Your code won't work if en_1 is a group.

For multiple groups:

{

_grp = _x;

{_x enablesimulation true} foreach units _grp;

} foreach [en_1,en_2,en_3];

Cheers

Share this post


Link to post
Share on other sites

Your code won't work if en_1 is a group.

For multiple groups:

{

_grp = _x;

{_x enablesimulation true} foreach units _grp;

} foreach [en_1,en_2,en_3];

Cheers

 

Thank you Gentlemen

Share this post


Link to post
Share on other sites

Your code won't work if en_1 is a group.

Im confused, you literally changed nothing to his code, just made it prettier.

Share this post


Link to post
Share on other sites

Im confused, you literally changed nothing to his code, just made it prettier.

He was referring to the OP's code, you could easily see mistake with using group command on a group.

  • Like 1

Share this post


Link to post
Share on other sites

He was referring to the OP's code, you could easily see mistake with using group command on a group.

Ah, I thought it was for the post above his, fair enough

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

×