• 🏆 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!

[JASS] How to exit loop?

Status
Not open for further replies.
Level 33
Joined
Mar 27, 2008
Messages
8,035
From what I understand;
I want 2 different exit loop functions:

I believe you should use OR function, right ?
Either condition should be fine, exit loop either your picked unit has buff, or your Boolean is equal to True.

Or the other way around ?
Both must be true ? (Picked unit has buff + Boolean is True) ?
 
Level 5
Joined
Jun 24, 2012
Messages
112
From what I understand;


I believe you should use OR function, right ?
Either condition should be fine, exit loop either your picked unit has buff, or your Boolean is equal to True.

Or the other way around ?
Both must be true ? (Picked unit has buff + Boolean is True) ?

No, no seperate. Each is for different loops.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
So you mean each condition is not meant for each other ?
So this is somewhat 2 separate function, eh ?

If you want to check a certain condition over-time, direct loop is never the answer.

You should use the Event Time - Periodic Event so that you can evaluate the condition each time.

The method you currently used is a direct looping which checks the condition for several times (but in a single period) where you should constantly checking the condition, that's why we use that Event.

Let's say we take a 0.10 second of Periodic Time event.

So, each 0.10 second pass, you make a check, this way you will evaluate those conditions per 0.10 second.
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,191
There is no limit to the number of "exitwhen" clauses a loop can have in WarCraft III.

In programming languages like C this is obtained by using the "break" statement (which JASS does not have). The use is to allow early exits from complex loops without having to reach the end.

In simple loops you can often tie the logic together using the logical "and" and "or" operators.
 
Status
Not open for further replies.
Top