• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Variables using array

Status
Not open for further replies.
Level 9
Joined
Jun 26, 2005
Messages
511
how do i make a variables that keeps making array for it self?
for ex.

do integer 1-50
-create dummy unit for player 1
-set temp unit[0 + 1] = last created unit

now the thing is i want the variable to do +1 +2 +3, so it would store all created units but i cant seem to get it to work.
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
Well, you can declare a Ineger and raise its value by 1 each time you create a unit, like this

  • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
  • Set Unit[Integer] = (Last created unit)
  • Set Integer = (Integer + 1)

However, in my opinion, the best way to do this is using a loop like this (in case you are creating them one after another)

  • For each (Integer A) from 1 to 50, do (Actions)
    • Loop - Actions
      • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
      • Set Unit[(Integer A)] = (Last created unit)

When the loop runs its "1" (first time it runs), it will set your unit to Unit[1], when it runs its "2" it will set it to Unit[2] and so on untill 50.

 
Level 19
Joined
Aug 24, 2007
Messages
2,888
Tip: Put a Custom script: call DestroyGroup(bj_lastCreatedGroup)

CreateNUnitsAtLoc (Unit - Create ...) Creates an Unit Group and its bj_lastCreatedGroup
(bj_wantDestroyGroup doesnt work because it doesnt check that variable nor contains anything to destroy that group)
 
Status
Not open for further replies.
Top