[Trigger] 'While' loop???

Status
Not open for further replies.
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.
Back
Top