• 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.

For each integer question

Status
Not open for further replies.
Level 7
Joined
Jul 12, 2008
Messages
295
Hey guys, i made a trigger for my spell that creates many units at the targeted point.. Now i want when something happens to remove them. When i use Unit - Remove Mist_of_Dust_Units[3,4 or 5] it obviously removes only 1 unit. And i don't know how to remove them all... Help me plz, +rep. Here is the trigger:

  • For each (Integer A) from 1 to 10, do (Actions)
    • Loop - Actions
      • Unit - Create 1 Dust Effect1 for (Owner of Mist_Of_Dust_Units[1]) at Mist_Of_Dust_Point facing Default building facing degrees
      • Set Mist_Of_Dust_Units[3] = (Last created unit)
      • Unit - Create 1 Dust Effect2 for (Owner of Mist_Of_Dust_Units[1]) at Mist_Of_Dust_Point facing Default building facing degrees
      • Set Mist_Of_Dust_Units[4] = (Last created unit)
      • Unit - Create 1 Dust Effect3 for (Owner of Mist_Of_Dust_Units[1]) at Mist_Of_Dust_Point facing Default building facing degrees
      • Set Mist_Of_Dust_Units[5] = (Last created unit)
The dust Effect1,2,3 are dummies
 
Level 7
Joined
Jul 12, 2008
Messages
295
Hmm, but would i be able to remove them if i place: Unit - Remove Mist_of_Dust_Units[(Integer A)] from the game in another trigger not in the same 1?
 
Level 13
Joined
Sep 29, 2008
Messages
672
yes, but don't forget to add that "For each integer" action, to make that action loop.


btw, you can set the one you made to this.
  • For each (Integer A) from 3 to 5, do (Actions)
    • Loop - Actions
      • Unit - Create 1 Dust Effect1 for (Owner of Mist_Of_Dust_Units[1]) at Mist_Of_Dust_Point facing Default building facing degrees
      • Set Mist_Of_Dust_Units[(Integer A)] = (Last created unit)
The action above will create the unit 3 times because it starts from 3 then that integer A array will loop till it hits 5.

I just copied the contents of your loop. Yours seems to start from 1 to 10. which means yours will create 3 units every loop which will loop 10 but it overrides the variables Mist_Of_Dust_Unit[3][4]and[5] over and over again.

I don't understand some points of the question though. xD
 
Level 7
Joined
Jul 12, 2008
Messages
295
Hmm, u know what i need right? I've made a spell that creates 30 dusts at a point... I want to remove them when something happens.. For example when my unit casts another spell those dusts to disappear... Btw: For each(Integer A) from X to Y do (Actions) and then remove my units, i think that will malfunction with some other triggers that have for each integer A actions.. Explain if u can plz
 
Level 13
Joined
Sep 29, 2008
Messages
672
you should have done it like this create a new group named Mist_Of_Dust_Group

  • For each (Integer A) from 1 to 30, do (Actions)
    • Loop - Actions
      • Unit - Create 1 Dust Effect1 for (Owner of Mist_Of_Dust_Units[1]) at Mist_Of_Dust_Point facing Default building facing degrees
      • Unit Group - Add (Last created unit) to Mist_Of_Dust_Group
Then remove them like this
  • Unit Group - Pick every unit in Mist_Of_Dust_Group and do (Actions)
    • Loop - Actions
      • Unit - Remove (Picked unit) from the game

Or if you really want the units to be set on the variables
  • For each (Integer A) from 1 to 30, do (Actions)
    • Loop - Actions
      • Unit - Create 1 Dust Effect1 for (Owner of Mist_Of_Dust_Units[1]) at Mist_Of_Dust_Point facing Default building facing degrees
      • Set Mist_Of_Dust_Units[(Integer A)] = (Last created unit)
The loop above will create 30 units and will set them in variables.
Mist_Of_Dust_Units[1]
Mist_Of_Dust_Units[2]
Mist_Of_Dust_Units[3]
.
.
Till it reaches the max loop
.
Mist_Of_Dust_Units[30]

I think in your trigger your array starts from 3 right?

  • For each (Integer A) from 3 to 33, do (Actions)
    • Loop - Actions
      • Unit - Create 1 Dust Effect1 for (Owner of Mist_Of_Dust_Units[1]) at Mist_Of_Dust_Point facing Default building facing degrees
      • Set Mist_Of_Dust_Units[(Integer A)] = (Last created unit)
The loop above will create 30 units also but will set them in variables
Mist_Of_Dust_Units[3]
Mist_Of_Dust_Units[4]
Mist_Of_Dust_Units[5]
.
.
Till it reaches the max loop
.
Mist_Of_Dust_Units[33]

from
  • For each (Integer A) from 1 to 30, do (Actions)
to
  • For each (Integer A) from 3 to 33, do (Actions)
Both actions above will loop 30 times but the one with the 3 will start its loop from number 3 which your array variable starts with.

then to remove them create another loop like this

  • For each (Integer A) from 3 to 33, do (Actions)
    • Loop - Actions
      • Unit - Remove Mist_of_Dust_Units[(Integer A)] from the game
SOrry if it isn't clear for you. I'm terrible at explaining stuff. xD
 
Status
Not open for further replies.
Top