• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

How to make 2 loops activate at the same time

Status
Not open for further replies.
Level 33
Joined
Mar 27, 2008
Messages
8,035
to fix this, you use variables for the integers, make two variable for each integer A you want to run :3
Just use 1 global variable to run looping function.

For example, these triggers work flawlessly;

  • Loop 1
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer LoopingInteger) from 1 to 5, do (Actions)
        • Loop - Actions
          • Game - Display to (All players) the text: Hello
  • Loop 2
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer LoopingInteger) from 1 to 5, do (Actions)
        • Loop - Actions
          • Game - Display to (All players) the text: World
The global variable is that Integer variable named LoopingInteger you see in those triggers.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
No.
Because in JASS script, you can see this clearly.
Each time before the loop function is done, the value of that global is set to 0.
Therefore, the data is reset each time it will be used.
Also, you have to remember that Warcraft III is single-threaded, therefore the data is safe and can never collide.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Ah, it will work, for each loop, you have to create a new Integer variable.

I tested this and it works;

  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • For each (Integer LoopingIntegerA) from 1 to 5, do (Actions)
        • Loop - Actions
          • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
          • Wait 1.00 seconds
  • Melee Initialization Copy
    • Events
      • Map initialization
    • Conditions
    • Actions
      • For each (Integer LoopingIntegerB) from 1 to 10, do (Actions)
        • Loop - Actions
          • Unit - Create 1 Peasant for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
          • Wait 1.00 seconds
  • Melee Initialization Copy Copy
    • Events
      • Map initialization
    • Conditions
    • Actions
      • For each (Integer LoopingIntegerC) from 1 to 15, do (Actions)
        • Loop - Actions
          • Unit - Create 1 Knight for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
          • Wait 1.00 seconds
Remember, each loop, you should use a new integer variable.

Variables:
LoopingIntegerA
LoopingIntegerB
LoopingIntegerC
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
What about my question? Would it work with different loop integers?

y, u can do something like that
  • blabla
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Custom script: local integer i = udg_Last_Index + 1
      • Custom script: set udg_Last_Index = i
      • For each (Integer Integer[Last_Index]) from 1 to 10, do (Actions)
        • Loop - Actions
          • Wait 1.00 seconds
          • -------- do action --------
      • Custom script: set udg_Current_Index = i
      • Set Integer[Current_Index] = Integer[Last_Index]
      • Set Last_Index = (Last_Index - 1)
if u want only 1x then just use more integer variable like: a,b ,c,d, e.... how many u need
 
Status
Not open for further replies.
Top