OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Blip 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:
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:
-
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)
-
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.
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:
-
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
-
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: