Jump to content
Sign in to follow this  
Ice_Rhino

_x Meaning??

Recommended Posts

I see in a lot of script the value of _x. Could someone tell me what this means?

Share this post


Link to post
Share on other sites

_x is the "current" value of an array that's being processed through a count or forEach command. It will be replaced by the actual value in each iteration.

_people = [bob, ned, sally];

{
   _x setDamage 1;
} forEach _people;

In that example you take an array with three elements, bob, ned and sally. We're assuming those are objects. We loop through the list, one at a time, using the forEach command. Each time through we execute this command:

_x setDamage 1;

First time through _x will be replaced with the first element of _people, in this case bob. So the three commands that structure will execute are, in turn:

bob setDamage 1;
ned setDamage 1;
sally setDamage 1;

So it's a placeholder for the current value of the array being worked through.

  • Like 1

Share this post


Link to post
Share on other sites

_x is a placeholder used mainly for the foreach and count command.

For example the following will replace _x with the name with each unit in AlphaGroup

{
_x;
hint format ["%1",_x]
}foreach units AlphaGroup; 

So if i am in AlphaGroup a hint will show saying "BangaBob". Not "_x"

  • 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
Sign in to follow this  

×