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

[Trigger] 'While' loop???

Status
Not open for further replies.
Level 40
Joined
Dec 14, 2005
Messages
10,532
Yes, Jass loops work completely different than GUI ones.

JASS:
loop
    exitwhen BOOLEAN //pretty much a conditional break statement.
endloop

For example, how the GUI loop works (<> means text representing a value)

JASS:
local integer i = <STARTING INTEGER VALUE>
loop
    exitwhen i > <ENDING INTEGER VALUE>
    //actions
    set i = i + 1
endloop

However, exitwhen can be at any point within the loop, for example;

JASS:
loop
    exitwhen true
    call BJDebugMsg("hi")
    call BJDebugMsg("hi")
endloop
//No text is displayed

loop
    call BJDebugMsg("hi")
    exitwhen true
    call BJDebugMsg("hi")
endloop
//Hi is displayed once

loop
    call BJDebugMsg("hi")
    call BJDebugMsg("hi")
    exitwhen true
endloop
//Hi is displayed twice

A loop may also have multiple exitwhens.

Oh, and since the GUI loops work as stated above, if you just make them 1 to 99999 and then add a Custom Script with exitwhen <whatever>, it will work fine.
 
Status
Not open for further replies.
Top