• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

exit the loop

Status
Not open for further replies.

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,183
hey, im making a system converted from jass or well the idea is from a system, anyway I want it to exit a loop when true but it does not seem to work.
  • For each (Integer A) from 1 to ID, do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • something here
        • Then - Actions
          • Custom script: exitwhen udg_check = true
          • Set check = True
          • Game - Display to (All players) the text: true
        • Else - Actions
          • Set check = False
          • Game - Display to (All players) the text: false
EDIT; fixed
 
  • Custom script : loop
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • something here
    • Then - Actions
      • Set check = True
      • Game - Display to (All players) the text: true
    • Else - Actions
      • Set check = False
      • Game - Display to (All players) the text: false
  • Custom script : exitwhen udg_check == True
  • Custom script : endloop
I'm not 100% sure of that first solution as i'm not a Jasser x) you also have that trigger :

  • For each (Integer IntVar) from 1 to ID, do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • something here
        • Then - Actions
          • Set IntVar = ID
          • Set check = True
          • Game - Display to (All players) the text: true
        • Else - Actions
          • Set check = False
          • Game - Display to (All players) the text: false
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
I don't think you need to reset "check" to false the entire time. Once before the loop is enough.
Because you set it to true after the exitwhen, it will go like this:

false
false
true (NO exitwhen, it is only set to true after the exitwhen check)
false (no exitwhen either! The variable is reset to false)
... (continue like this)

Do you want it to exit directly after the condition ("something here") is true? Then you can just do exitwhen true at the end of the Then-section and drop the "check"-variable altogether.
If you want it to exit 1 iteration after the condition is true, then remove the "Set check = false".

You can also create a loop with custom script only.
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,183
I converted it to jass a found a solution, thanks for the help tho, reped
  • GUI
    • For each (Integer A) from 1 to ID, do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
          • Then - Actions
            • Custom script: set bj_forLoopAIndex = bj_forLoopAIndexEnd
            • Set check = True
            • Game - Display to (All players) the text: true
          • Else - Actions
            • Set check = False
            • Game - Display to (All players) the text: false
 
Last edited:
Status
Not open for further replies.
Top