Looping multiple times using IntegerA

Julian4life

New Member
Reaction score
7
Hey there TH.net!

First off, heres the settings, or whatever you want to call it:
The Spawn Region Arrays
Low Spawn Arrays
Events
Map initialization
Conditions
Actions
Set LowSpawns[1] = (Center of LowCreepSpawn1 <gen>)
Set LowSpawns[2] = (Center of LowCreepSpawn2 <gen>)
Set LowSpawns[3] = (Center of LowCreepSpawn3 <gen>)
Set LowSpawns[4] = (Center of LowCreepSpawn4 <gen>)
Set LowSpawns[5] = (Center of LowCreepSpawn5 <gen>)
Set LowSpawns[6] = (Center of LowCreepSpawn6 <gen>)
Set LowSpawns[7] = (Center of LowCreepSpawn7 <gen>)
Set LowSpawns[8] = (Center of LowCreepSpawn8 <gen>)
Set LowSpawns[9] = (Center of LowCreepSpawn9 <gen>)
Set LowSpawns[10] = (Center of LowCreepSpawn10 <gen>)
Set LowSpawns[11] = (Center of LowCreepSpawn11 <gen>)
Set LowSpawns[12] = (Center of LowCreepSpawn12 <gen>)
Set LowSpawns[13] = (Center of LowCreepSpawn13 <gen>)
Set LowSpawns[14] = (Center of LowCreepSpawn14 <gen>)
Set LowSpawns[15] = (Center of LowCreepSpawn15 <gen>)
Set LowSpawns[16] = (Center of LowCreepSpawn16 <gen>)
... so on, continuing with different spawning regions.

The Trigger using the arrays
Low Spawn
Events
Time - Elapsed game time is 2.00 seconds
Conditions
Actions
For each (Integer B) from 1 to 16, do (Actions)
Loop - Actions
Unit - Create 1 Ghoul for Player 12 (Brown) at LowSpawns[(Integer A)] facing Default building facing degrees


With this, im trying to cause those 16 spawn points to spawn ghouls. And, so far, so good. Each of the 16 spawn points spawn a ghoul. Which brings us to my small dilema. I want the regions to continuously spawn ghouls (a total of 15 times to be exact) every 2 seconds from each region. I wasnt sure how to pull it off, and i messed with everything, but it didnt exactly work out. (i was plainly going to just copy-paste the ghouls and timing, but since there are about 30 different creeps, and 15 waves of each... that would make a longgggg trigger. :banghead:

Does anyone know a solution to this? How to have it so it spawns 15 times, every 2 seconds, then stops, and moves on to my next trigger? Or how to make it continue to loop throught only those 16 integers.
 

Nerfpl

New Member
Reaction score
53
B not A
or A instead of B
For each (Integer B) from 1 to 16, do (Actions)
Loop - Actions
Unit - Create 1 Ghoul for Player 12 (Brown) at LowSpawns[(Integer A)] facing Default building facing degrees
 

Chris B

New Member
Reaction score
7
Wait, so do you want it to spawn 15 units in every region every 2 seconds?

Also, what Nerf is saying is that you are looping B but using A's variable. They must be the same. They do this in case you're using multiple loops I think (so you can refer to A or B in the same trigger)

-Chris
 

Nerfpl

New Member
Reaction score
53
Wait, so do you want it to spawn 15 units in every region every 2 seconds?

Also, what Nerf is saying is that you are looping B but using A's variable. They must be the same. They do this in case you're using multiple loops I think (so you can refer to A or B in the same trigger)

-Chris

Actually you can use A/B loop countless in 1 trigger. i think A&B is for loop in loop
 

Chris B

New Member
Reaction score
7
Nerf, that's what I mean. By multiple loops I meant loops inside of loops....I've been doing this all day. I've had an off day and have been having the worst time trying to explain things to people lol, and to make it worse I've been eating junk food all day :p

@J4L
If you utilize loops inside of loops BTW, and was actually doing it so that it creates 15 units per spawn location, do something like the following (Not Tested):

Trigger:
  • Events
    • Time - Elapsed game time is 2.00 seconds
    • Conditions
    • Actions
      • For Each (Integer A) From 1 to 16 do (Actions)
        • Loop (Actions)
          • For Each (Integer B) From 1 to 15 do (Actions)
            • Loop (Actions)
              • Unit - Create 1 Ghoul for Player 12 (Brown) at LowSpawns[(Integer A)] facing Default building facing degrees
              • Wait 2.00 Seconds


If I'm not mistaken, the following will loop through 16 times, hitting the spawn point each time. The second loop (B) will loop at EVERY spawn point, taking turns one at a time. What it will do is first spawn a unit unit every 2 seconds at spawn Integer A, and once it's finished, it waits 2 seconds, then does the following for the next spawn point. Does this help? Or was it something else you needed?

-Chris

BTW, if I helped you, and you feel like helping me, I accept +rep. That's all I ask, and I'm happy :D Need to hit that 100rep mark lol....and only at 3. I guess you gotta yell out that you want rep to get it sometimes haha.
 

Kelvin87

New Member
Reaction score
14
Loop integer A and Loop integer B can't be meshed up! The Trigger will not be functioning if the variable integer A "ONLY" exists in Loop integer B. Perhaps The loops will still running, just the looping integer value of the variable adding up is different. for Loop integer B, the value will be adding up to bj_forLoopBIndex; for Loop integer A, the value will be adding up to bj_forLoopAIndex.
 

Chris B

New Member
Reaction score
7
@Kelvin
It will still function, but A will be added, while B still remains 1, or 0, whatever the default is. I'm assuming that's what you meant, but if not wanted to clarify :p

-Chris
 

Kelvin87

New Member
Reaction score
14
Set LowSpawns[0] = (Center of LowCreepSpawn1 <gen>)
......
Set LowSpawns[9] = (Center of LowCreepSpawn10 <gen>)

For each (Integer A) from 0 to 9, do (Actions)
Loop - Actions

1. Please take notes to the value you used. The Array value will start from "0"

2. Don't use wait in loop.

3. Use a single loop is enough. PLease avoid to use Loop-In-Loop
 

Julian4life

New Member
Reaction score
7
Hmm, kelvin, could you free hand or create a sample trigger to use in that situation?

Basically copy n paste from my topic post quotes and fill in what i would do?


EDIT:
<@Chris

Thats a good idea, well ofcourse unless its ofset by what kelvin said, and i tested it. The thought of the trigger is a good idea, except if you think carefully, you'll see that what that trigger will actually do is have one location spawn 1 at a time every 2 seconds to make 15 ghouls, THEN it'll go to spawn location 2 and repeat till spawn location 16. I want each location to spawn one at a time at the same time. And repeat for 15 times.
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
2. Don't use wait in loop.

3. Use a single loop is enough. PLease avoid to use Loop-In-Loop

2. Wait is fine inside Integer A/B/Variable loops. It's Player Group/Unit Group loops that cannot have waits. The only problem is that they're not MUI, so if another loop runs after another one waits, it will change the Integer A counter.

3. You can put A's in B's, B's in A's, etc. Just don't put A's in A's or B's in B's. It will skip many of the indexes. This also means that if you only use A and B loops, you can only have 1 outter loop, and one inner loop. If you try another one inside, it will mess up the indexes. Instead, you can use the "For Each (Integer Variable)".

Also, Pick Every Player/Unit in Force/Group works fine, but there's no way to refer to the outer "picked unit" inside an inner Pick Every loop. You CAN do it with variables, though. (Picked unit) will always refer to the innermost pick every... unit.

Loops cannot go backwards. If the start value is higher than the end value, it will end after 1 or 0 iterations (I don't remember which).

Pick Every ... loops do not get iterated through in any specific order (there IS an order, and it's probably something to do with the order they are added into the group). Just don't expect Pick every unit in (Range) ... to iterate through the units closest to the center first, and farthest away last.

The ONLY difference between Integer A loops, and Integer B loops is the variables. Since they use different variables, they can be placed inside of eachother.
 

Chris B

New Member
Reaction score
7
<@Chris

Thats a good idea, well ofcourse unless its ofset by what kelvin said, and i tested it. The thought of the trigger is a good idea, except if you think carefully, you'll see that what that trigger will actually do is have one location spawn 1 at a time every 2 seconds to make 15 ghouls, THEN it'll go to spawn location 2 and repeat till spawn location 16. I want each location to spawn one at a time at the same time. And repeat for 15 times.[/QUOTE]

Oh, ok, I misread your post. Try this:
Trigger:
  • Events
    • Time - Elapsed game time is 2.00 seconds
    • Conditions
    • Actions
      • For Each (Integer A) From 1 to 15 do (Actions)
        • Loop (Actions)
          • For Each (Integer B) From 1 to 16 do (Actions)
            • Loop (Actions)
              • Unit - Create 1 Ghoul for Player 12 (Brown) at LowSpawns[(Integer B)] facing Default building facing degrees
          • Wait 2.00 Seconds


Now it should loop 15 times (for 15 units), and every time it loops, it will create one unit at all 16 spots, THEN wait 2 seconds. I believe this is what you want, correct? Let me know whether it works or not.

-Chris
 

Julian4life

New Member
Reaction score
7
chris, i didn't test this yet, but, i'm fairly sure by simply looking at it, it'll cause 15 to spawn all at once on one spawn point, then wait 2 seconds, and move on to spawn point two and repeat.

Does anyone have a way to solve this?
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
chris, i didn't test this yet, but, i'm fairly sure by simply looking at it, it'll cause 15 to spawn all at once on one spawn point, then wait 2 seconds, and move on to spawn point two and repeat.

Does anyone have a way to solve this?

Chris' method is correct. It changes the spawn point each time the B actions are run. It will create one unit at each spawn point, wait 2 seconds, and repeat this for 16 times. Just remember that it will still wait 2 seconds after the units have all spawned before continuing the trigger.
 

Julian4life

New Member
Reaction score
7
<@I_RULE_YOU
honestly, i didn't really need to have you tell that too me. i wasn't "bumping" my thread, i was replying. Btw, its 11:05 for me at my place. I never said i was expecting a hundred replies okay?

<@darthfett
haha. i realized that just now, i realized he switched the integers which changed the whole process. +rep'd

<@chrisB
thanks for all the help. happily +rep'd
 

Chris B

New Member
Reaction score
7
Cool, thanks for the rep, glad I could help :)

But yea, I did some minor modifications which made a huge difference lol. It was all a matter of moving things around :)

-Chris
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top