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

how to break out of loop?

Status
Not open for further replies.
Level 5
Joined
Sep 22, 2012
Messages
90
not exactly dood, I also did that like to find a bullet speed out of my array and used an if-statement to store the for loop index. What i meant is if multiple conditions are inside the loop.
 
Level 4
Joined
Jan 27, 2010
Messages
133
Alima, he doesn't need to script the entire loop...

Use Custom Script and write: exitwhen true
Will break out of the loop.

  • Untitled Trigger 001
    • Events
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 10, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • OR
                • (Integer A) Equal to 3
                • WorldEndsToday
                • Som other condition
            • Then - Actions
              • Custom script: exitwhen true
            • Else - Actions
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
He did not mention a Sentinel Loop or a Controlled Loop.

Sentinel Loop uses condition/status that is either true/false.
Controlled Loop uses counter that if certain limit is achieved, it exits the loop.

Now, which Loop are you referring to ?

Sentinel Loop Example;
  • Sentinel Loop
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering unit) is alive) Equal to True
        • Then - Actions
        • Else - Actions
          • Trigger - Turn off (This trigger)
Controlled Loop Example;
  • Controlled Loop
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: local integer i = 10
      • Custom script: local integer counter = 0
      • Custom script: loop
      • Custom script: exitwhen counter > i
      • Custom script: set counter = counter + 1
      • Custom script: endloop
 
Level 16
Joined
Mar 3, 2006
Messages
1,564
From what your title suggest (break) means exit before the original exit conditions are matched.

So IMHO :wink: , best to do this:
  • Actions
    • For each (Integer A) from 1 to 10, do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • ((Player((Integer A))) slot status) Equal to Is unused
          • Then - Actions
            • Custom script: exitwhen true
          • Else - Actions
        • Item - Create Tome of Experience at ((Player((Integer A))) start location)

JASS:
// some functions above
        loop
            if not IsStringInteger(SubString(inputVal[1],i,i+1)) then
                call BJDebugMsg("Valid Command - Invalid Inputs")
                set inputNotValid[1] = true
                exitwhen true
            endif
            set i = i + 1
            exitwhen i == inputValLength[1]
        endloop
// some function below
 
Status
Not open for further replies.
Top