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

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