• 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] End Loop

Status
Not open for further replies.
Level 16
Joined
Dec 15, 2011
Messages
1,423
Oh I see. My bad :p

Well there are a few ways to get around like clearing the entire enum group or killing the unit current being iterated.

There isn't a one-size-fits-all solution as far as I know :p

EDIT: But it all goes down to the condition in the end so I myself think that there isn't a way to skip that :p
 
Level 7
Joined
Nov 15, 2009
Messages
225
You need the exitwhen line.

But you don't need the integer variable.

You can, for example, change it to a boolean and check if its true or not.

JASS:
globals
    boolean abc = false
endglobals

function Whatever takes nothing returns nothing
    loop
        call BJDebugMsg("test")
        if abc == true then
            exitwhen true
        endif
        call PolledWait(0.2)
        set abc = true // to make doom happy..^^
    endloop
endfunction
 
Last edited:
Level 28
Joined
Jan 26, 2007
Messages
4,789
I'd just like to note that this also works:
JASS:
function LoopFunction takes nothing returns nothing
    local integer i = 0
    
    loop
        exitwhen i >= 10 // Regular exitwhen
        
        // Action block 1
        
        if boolexpr then
            // Exiting the loop
            exitwhen true
        endif
        
        // Action block 2
        
        set i = i+1
    endloop
endfunction
In case you want to exit the loop after Action block 1, but still do something special (like giving an item to a unit or whatever).

You don't see this very often though :p
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
from I dont know which patch null boolexprs wont null(the proof of this is using nulls as boolexpr to groupenum functions and triggerevents, they even stated several times(users) that it not longer leaks), even Blizzards BJS uses null as boolexpr to trigger events
however to if you should rather say boolean than boolexpr
trying to fit boolexpr within if and then will cause compiler errors
Cannot convert boolean to boolexpr
 
Status
Not open for further replies.
Top