Home   Help Search Login Register  

Author Topic: Add single unit to an array?  (Read 594 times)

0 Members and 1 Guest are viewing this topic.

Black Operative

  • Guest
Add single unit to an array?
« on: 11 Jun 2003, 11:48:22 »
I want to make an array out of several single units operating on their own so I can later use it to make all of them join the player's group. Does anyone know how I can add a specific unit to an array?

Thx in advance! :)

Offline Sui

  • Former Staff
  • ****
    • OFPEC
Re:Add single unit to an array?
« Reply #1 on: 11 Jun 2003, 12:37:15 »
How would you like to add the unit exactly?

Do you just want to tack it onto the end of the array, like so:

array = array + [ unit ]    ?

or would you like to specify a position in the array for the unit to go, like this:

array set [ n, unit ]      

(where n is the position in the array) ?

or would you rather make an array out of all the units inside a trigger, like this:

array = thislist  (in the Onactivation line of a present trigger) ?

Do any of those help you out at all? ;)

Black Operative

  • Guest
Re:Add single unit to an array?
« Reply #2 on: 11 Jun 2003, 13:42:44 »
Well, I'd rather like to know how I can make an array of units in the first place.  ;D

I have a plain example:
I have three independent soldiers called Alpha1, Alpha2 and Alpha3 and the player (called AP). Then there's a "true" trigger that should add Alpha1 to an array called MyGroup, like this:

MyGroup = MyGroup + [Alpha1]

Same thing with Alpha2 and Alpha3. On "radio Alpha" this is activated:
[MyGroup] join (group AP)

So that the units in the array that was defined before now join the player.


In simple words: I want a flexible (= able to be modified in a script as I do not know who will be alive and who won't at that point of the mission) array that I can use with the join command. :)

Offline Tomb

  • Contributing Member
  • **
  • in2 Metal? Go 2 my sig
Re:Add single unit to an array?
« Reply #3 on: 11 Jun 2003, 16:23:54 »

[MyGroup] join (group AP)



  uuuum, to make several d00ds join someone, try this:

morons = [a,b,c]; "[_x] join grpNull" foreach morons; "[_x] join Bob" forEach morons

-where 'bob' s the groupLeaderName.  :)



(ps. you prolly don't even need the "join grpNull" part)

« Last Edit: 11 Jun 2003, 16:25:05 by Tomb »

Black Operative

  • Guest
Re:Add single unit to an array?
« Reply #4 on: 11 Jun 2003, 22:14:04 »
You can also simply write "morons join Bob", thus avoiding nasty "follow" commands for every single unit in the array. :)

Anyway, problem solved, thanks buddies!  8)