• 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] Why is wait in For Loop function so slow?

Status
Not open for further replies.
Level 8
Joined
Oct 19, 2008
Messages
168
If i use the wait action inside of the "For Loop Integer Function" ,it does it very slow in game, not what i expect at Wait .01 seconds?

It'll do it over like 1.5 seconds when it should be like .10

Why is that?
 
The "Wait" function is rather inaccurate. It varies from time to time, and the minimum wait tends to vary from 0.1-0.3 seconds (and it may vary depending on other factors).

You should use a periodic trigger instead. It'll give you the accuracy in timing you need. It is impossible to do with just waits. It'll look very choppy. Perhaps you should read either one of these to get started:
http://www.hiveworkshop.com/forums/...orials-279/visualize-dynamic-indexing-241896/
http://www.hiveworkshop.com/forums/trigger-gui-editor-tutorials-279/general-spell-creation-236141/
 
If i use the wait action inside of the "For Loop Integer Function" ,it does it very slow in game, not what i expect at Wait .01 seconds?

It'll do it over like 1.5 seconds when it should be like .10

Why is that?
It's because the wait adds up over every loop operation.

0.1*15 = 1.5 seconds.
 
Level 8
Joined
Oct 19, 2008
Messages
168
ohhhhh ok that makes a lot more sense guys thanks, and the periodic trigger works great.

But what about if i make a simple trigger For Loop 1-20 with a wait of 2 seconds in each one? Is that long enough of a wait for it to be accurate?
 
ohhhhh ok that makes a lot more sense guys thanks, and the periodic trigger works great.

But what about if i make a simple trigger For Loop 1-20 with a wait of 2 seconds in each one? Is that long enough of a wait for it to be accurate?

Yeah, 2 seconds is usually long enough. It won't be any more accurate (it'll still be off by some milliseconds = same error), but you won't notice it as easily. Think of it this way:

If you are tapping your desk once every 5 minutes, you won't notice if you're a second off. You may end up tapping it once every 5 minutes + 1 second, or maybe 5 minutes - 1 second. Either way, you probably won't notice that you were off by a second.

However, if you were tapping your desk every half a second, then you would definitely notice a 1 second delay. You'll notice that it is going a lot, lot slower than you would expect.

That is the general rule of thumb to waits. You'll be fine with a long duration, but they are pretty awful for short durations. There are other reasons why waits are problematic, but some of it applies to JASS or they're very specific oddities, so don't worry about them unless you experience problems.
 
Status
Not open for further replies.
Top