• 🏆 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!

Need little help how to loop a IF/then/else

Status
Not open for further replies.
Level 1
Joined
Sep 3, 2008
Messages
2
Endless loop using if/then/else as action inside a trigger ?

I want: If a if/then/else statement is FALSE it loops the if/then/else statement until it is TRUE.
I do NOT want: if the if/then/else statement is FALSE continue the trigger.

Basically I want to use a if/then/else statement inside a trigger to hold execution of all actions that come AFTER the if/then/else.

(in commodore 64 basic this is what i want to do inside a wc3 trigger)
10 A=0
20 A=A+1
30 IF A=10 then goto 40 ELSE goto 20
40 continue the program from here...because A has reached value 10 after 10 cycles in the if loop

(inside wc3 this is how for i got)

Event:
Game time of day is 06.50

Action:
Set Variable A=0
IF A=10 then (do nothing) else Set A=A+1 (and now I need a command to repeat the IF statement)
Floating Text 'Integer<A> is finally 10 and the if statement looped 10 times'

What Action do I use at the ELSE statement to loop the if/then after the Set A=A+1 statement?
---------------------------------------------------------------------------------------------

By the way:
Is there a boolean-check I can make on a Unit to see if its walking or not?

Thanks in advance SO much,
Carda
 
Last edited:
Level 21
Joined
Aug 21, 2005
Messages
3,699
In GUI you have the For loop:

  • For each Integer A from 1 to 10 do:
    • Loop - actions
Which is basically what you wanted.

In jass, you can create "real" loops:
JASS:
loop
    exitwhen condition == true
    do stuff
endloop
The jass version of the GUI for-loop would be:
JASS:
local integer iterator = 0
loop
    exitwhen iterator >= 10
    set iterator = iterator + 1
endloop
 
Status
Not open for further replies.
Top