Home   Help Search Login Register  

Author Topic: Group Array  (Read 500 times)

0 Members and 2 Guests are viewing this topic.

Offline Blip

  • Members
  • *
  • ...Old OFP FART...
Group Array
« on: 24 May 2005, 01:29:34 »
How would one go about passing a group of units through a script if said units are coming from an array that you defined in a script.

Example:
Quote
group1 = [guy1, guy2, guy3]
_group1 = group1
{ [_x] exec {move2.sqs} } foreach units _group1

Is this possible? Because I can't get it to work.

Blip :joystick:
...NIGHT WALKER....

Offline Raptorsaurus

  • Editors Depot Staff
  • *****
Re:Group Array
« Reply #1 on: 24 May 2005, 01:51:10 »
Your group1 is not a group, you are making it an array.  Lets say that the leader of group1 is guy1, then:

_group1 = group guy1 (actually it does not even have to be the leader, you would get the same "value" for group1 if you said:

_group1 = group guy2

OK, next step:

{[_x] exec "move2.sqs"} forEach units _group1

 That should do it.

In fact you could leave out the whole _group1 = group guy1.  You could just have one line:

{[_x] exec "move2.sqs"} forEach units (group guy1)

Offline Blip

  • Members
  • *
  • ...Old OFP FART...
Re:Group Array
« Reply #2 on: 24 May 2005, 02:30:41 »
Hey Raptorsaurus-

What I actually want to do is be able to define which units would be part of the group that gets passed through the array.

So i want the following units: guy1, guy2, guy3 to get passed through the script even though these three units aren't part of the same group, or any group for that matter.

Quote
In fact you could leave out the whole _group1 = group guy1.  You could just have one line:

{[_x] exec "move2.sqs"} forEach units (group guy1)

This is kinda what i am shooting for except I want all the guys in the array to passed through the same call to the script.

Blip :joystick:
...NIGHT WALKER....

Offline Raptorsaurus

  • Editors Depot Staff
  • *****
Re:Group Array
« Reply #3 on: 24 May 2005, 03:47:41 »
Ah, OK, so you want the script to be executed by those three guys, but not necessarily the whole group?  If that is the case then do this:

guys = [guy1, guy2, guy3] ;

{[_x] exec "move2.sqs"} forEach guys

or you can do this:

{[_x] exec "move2.sqs"} forEach [guy1, guy2, guy3]

If you want the guys to be passed to the script together (instead of the script running three times for each guy, the script runs once for all the guys).

[guy1, guy2, guy3] exec "move2.sqs"

Then in the script:

_guy 1 = _this select 0
_guy 2 = _this select 1
_guy 3 = _this select 2

or if you want to keep them as an array of units the script would start like this:

_arrayOfguys = _this
« Last Edit: 24 May 2005, 03:52:45 by Raptorsaurus »

Offline Blip

  • Members
  • *
  • ...Old OFP FART...
Re:Group Array
« Reply #4 on: 24 May 2005, 04:10:56 »
Quote
guys = [guy1, guy2, guy3] ;

{[_x] exec "move2.sqs"} forEach guys

or you can do this:

{[_x] exec "move2.sqs"} forEach [guy1, guy2, guy3]

Thats what I needed.

Many thanks my friend. :thumbsup:

Blip :joystick:
...NIGHT WALKER....