OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: 999chris on 28 Mar 2005, 10:25:48

Title: What is _x
Post by: 999chris 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)?
Title: Re:What is _x
Post by: macguba 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.
Title: Re:What is _x
Post by: Raptorsaurus 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