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

[Trigger] Wait in Loops?

Status
Not open for further replies.
Level 9
Joined
Sep 28, 2004
Messages
365
I know that
  • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
    • Loop - Actions
and
  • Player Group - Pick every player in (All players) and do (Actions)
    • Loop - Actions
shouldn't use wait in it.

But what about others? Like:
  • For each (Integer A) from 1 to 10, do (Actions)
    • Loop - Actions
Can i use wait in this loop?
 
Level 7
Joined
May 3, 2007
Messages
210
Loop is a control structure, the only thing that changes is what you iterate through and what you do to the contents. The two above loops you listed iterate through every unit in a given group, same with players in a given playergroup for the second. The final just iterates 10 times doing whatever you want.

In short, don't.
 
Level 7
Joined
May 3, 2007
Messages
210
I don't know about GUI, but a loop isn't altered in structure by anything else, hence a waits effect on iterating through groups has no greater weight then iterating through anything else. It may be different in GUI.

Regardless, the purpose of a wait is to make the thread sleep for a given time (that time being higher then .25, because waits lose most of their reliability and precision after that number). So if you literally want the thread to do nothing for that given amount of time, then use the wait. However I doubt that's what you truly want.

In instance, a friend of mine uses waits in his neural network because he deliberately wants to put the thread to sleep, it works fine.
 
Level 12
Joined
Aug 22, 2008
Messages
911
Solution #1: Timers.
Solution #2: Triggers, make a trigger run itself after a wait action if a certain condition occurs, for example:
  • Actions
    • [Actions]
    • If (Value equal to 1) then do (All actions) else do (Do Nothing)
      • Then - Actions
        • Wait WTF seconds
        • Trigger - Run (This trigger) ignoring conditions
 
Solution #1: Timers.
Solution #2: Triggers, make a trigger run itself after a wait action if a certain condition occurs, for example:
  • Actions
    • [Actions]
    • Set player number [Value] with Actions
    • If (Value equal to 4) then do (All actions) else do (Do Nothing)
      • Then - Actions
        • Wait WTF seconds
        • Set Value = Value + 1
        • Trigger - Run (This trigger) ignoring conditions

Will make the trigger run itself 3 times with different values
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,201
Loop structures support use of wait as it executes them in a predictable order from beginning of loop to the end of the loop code where it repeats.

Enums on the other hand execute code a lot less predictably where they que a function to run for every object. Waiting in them will result in the thread crashing probably due to some stack management issue in the WC3 engine (incapable of handling it that parralel).

Just to make it clear, wait refers to TriggerSleepAction or simlar pauses.
 
Loop structures support use of wait as it executes them in a predictable order from beginning of loop to the end of the loop code where it repeats.

Enums on the other hand execute code a lot less predictably where they que a function to run for every object. Waiting in them will result in the thread crashing probably due to some stack management issue in the WC3 engine (incapable of handling it that parralel).

Just to make it clear, wait refers to TriggerSleepAction or simlar pauses.

And to make it clear even more, can we use it in a loop?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,201
If by "it" you mean TriggerSleepAction() (the "Wait" action in GUI) then yes, you may use it inside a loop structure.

For clarification a loop structure is. . .
JASS:
loop
//code here which will repeat until "exitwhen" structure is evaluated true.
endloop
Which is some kind of "for" structure emulation when used in GUI.

Anything enum related (for unit in group or for player in force or for destructable in range or position), can not use TriggerSleepAction() without causing a crash of the trigger (trigger stops execution passed that point like when division by 0 occurs).
 
Status
Not open for further replies.
Top