Home   Help Search Login Register  

Author Topic: What is _x  (Read 630 times)

0 Members and 1 Guest are viewing this topic.

Offline 999chris

  • Members
  • *
  • I'm a llama!
What is _x
« on: 28 Mar 2005, 10:25:48 »
Ive seen this... bit of script, pffft. Im so amateur I dont even know what to call it... command, variable? Its the wonderful "_x" now what is X? Is it some kind of Global Array or something?

So what can it be used for and how does it affect the script ("_x moveincargo jeep1" foreachunits grp1)?

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:What is _x
« Reply #1 on: 28 Mar 2005, 10:39:18 »
_x is a local variable.   In the context of forEach or count commands, it refers in turn to each of the members of the array, taken as a parameter by the command.    In other words it is local to the command.

In your example, _x refers to each member of the array "units grp1" in turn.
« Last Edit: 28 Mar 2005, 10:39:42 by macguba »
Plenty of reviewed ArmA missions for you to play

Offline Raptorsaurus

  • Editors Depot Staff
  • *****
Re:What is _x
« Reply #2 on: 28 Mar 2005, 17:20:28 »
So, in the example: {_x moveincargo jeep1} foreach units grp1.  Each member of grp1 1 will be assigned to _x then moved into the cargo space of jeep1.  It basically does the same as:

_men = units grp1
_cnt = 0
#loop
_xman = _men select _cnt
_xman moveInCargo jeep1
_cnt = _cnt + 1
If _cnt < (count _men) : goto "loop"

but with (as you can see) MUCH LESS CODE. ;D