waits in for loops?

Beast

New Member
Reaction score
5
How exactly does it execute them, because it seems to do it weird. Basically I'm just making a trigger that is a for loop from 1 to 10 and moves a unit backward a little then waits .5 seconds or so. What happens is it moves the whole way(10x the distance since the loop executes 10 times) then just waits after for .5 seconds instead of waiting .5 seconds after each time the loop runs if that makes sense. Is this just how it functions and is there a clever way to get around this?
 

Cidzero

Imma firin mah lazer!!!1!1
Reaction score
39
wait what?...

All I caught on to that is you have a wait trigger and a for loop that runs 10 times...

Are you asking how to get it to wait each time the loop runs? if so, then just put the wait inside the for loop...
 

Beast

New Member
Reaction score
5
wait what?...

All I caught on to that is you have a wait trigger and a for loop that runs 10 times...

Are you asking how to get it to wait each time the loop runs? if so, then just put the wait inside the for loop...

Thats how I have it, but it doesn't wait for each time the loop runs for some reason, it executes it all 10 times then waits after the 10, seems really weird just thought it might be a qwerk with the worldedit.
 

Somatic

You can change this now in User CP.
Reaction score
84
-Edit- Your problem is you need to put the
Code:
Wait 0.5 Seconds
inside the loop like this :
Code:
For every Interger A from 1 to 10
<Do actions>
Wait 0.5 second


to do sliding effects, use a timer, Using a Wait no matter how low u set it, it will still be 0.24 second.

An alternate method :

Use a trigger with this event
Code:
Event : Every 0.02 second of game time.

This will make a better slide or using of timers

Code:
Event : Slide_Timer Expires

For methods of doing this, search for "Sliding Tutorials"
 

Beast

New Member
Reaction score
5
Well it doesn't really seem to work, for example if i put...

For 1 to 10000
wait 1 second

it just waits 1 second, when it should wait 10000 right?
 

Somatic

You can change this now in User CP.
Reaction score
84
post your trigger, there might be a mistake in there. Wrap it with a Code tag too =)
 

Terrabull

Veteran Member (Done that)
Reaction score
38
Using a Wait no matter how low u set it, it will still be 0.24 second.

This information is false, please don't spread misinformation. Waits at low intervals have unreliable timings, but it is not capped at any certain time.
 

Somatic

You can change this now in User CP.
Reaction score
84
-Terrabull-
I'm very sorry but thats true.

Please read this tutorial for an example of a sliding spell.

http://www.thehelper.net/forums/showthread.php?t=22135

and a quote from it is this

Waiting 0.20 seconds will give us time to start the effect withouth getting disturbed by dummy spells casting time which makes us unable to touch our casting unit. However you cannot wait less then 0.2 seconds with wait function which is the reason that we use 2 triggers for this spell.
 

Beast

New Member
Reaction score
5
Heres the code, when it runs it takes .2 seconds (approx) to go from making the flight height go up to make it go down. If I take the loop out entirely and replace it with wait 2 seconds then it looks right(except the unit doesn't move backwards).
Code:
Catapult
    Events
        Unit - A unit Is attacked
    Conditions
        (Unit-type of (Attacking unit)) Equal to Catapult
    Actions
        Unit - Add Storm Crow Form to (Triggering unit)
        Unit - Remove Storm Crow Form from (Triggering unit)
        Unit - Turn collision for (Triggering unit) Off
        Unit - Pause (Triggering unit)
        Animation - Change (Triggering unit) flying height to 600.00 at 300.00
        For each (Integer A) from 1 to 10, do (Actions)
            Loop - Actions
                Unit - Move (Triggering unit) instantly to ((Position of (Triggering unit)) offset by (-50.00, 0.00))
                Wait 0.20 seconds
        Animation - Change (Triggering unit) flying height to 0.00 at 300.00
        For each (Integer A) from 1 to 10, do (Actions)
            Loop - Actions
                Unit - Move (Triggering unit) instantly to ((Position of (Triggering unit)) offset by (-50.00, 0.00))
                Wait 0.20 seconds
        Unit - Unpause (Triggering unit)
        Unit - Turn collision for (Triggering unit) On
        Unit - Order (Triggering unit) to Move To (Center of EndZone[((Player number of (Owner of (Triggering unit))) - 7)])
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
> I'm very sorry but that's true.

No, it's not. And now please stop posting that crap. Thank you.



Moving units like this is not a very good idea.
As the height depends on the terrain, every time you move it, the game will recalculate the elevation, which somewhat breaks the flying height change...

I'd suggest having a look at one of the many "jump" spells we have in the spells section.
 

Beast

New Member
Reaction score
5
> I'm very sorry but that's true.

No, it's not. And now please stop posting that crap. Thank you.



Moving units like this is not a very good idea.
As the height depends on the terrain, every time you move it, the game will recalculate the elevation, which somewhat breaks the flying height change...

I'd suggest having a look at one of the many "jump" spells we have in the spells section.

terrain won't be a problem as everything is flat. Also I just wanna keep it simple it can look a little jerky as long as it works right(which it doesn't).
 

Somatic

You can change this now in User CP.
Reaction score
84
-Acehart-

There is a new breakthrought? Is there any information regarding about setting wait time to low values? Thanks if there are any. Sorry fot eh mistake =X

-Beast-

That looked right... But i'm not sure what could be wrong. The wait is at the right place... The unit does slide or it just instantly moved?
 

Beast

New Member
Reaction score
5
-Acehart-

There is a new breakthrought? Is there any information regarding about setting wait time to low values? Thanks if there are any. Sorry fot eh mistake =X

-Beast-

That looked right... But i'm not sure what could be wrong. The wait is at the right place... The unit does slide or it just instantly moved?

It moves twice(1 for each loop). I tried it in a blank map(just something like for 1 to 50 display integer A wait 1 second and it works fine so I guess it should work. Not exactly sure why mine doesnt =(.
 

Beast

New Member
Reaction score
5
Code:
Catapult
    Events
        Unit - A unit Is attacked
    Conditions
        (Unit-type of (Attacking unit)) Equal to Catapult
    Actions
        Unit - Add Storm Crow Form to (Triggering unit)
        Unit - Remove Storm Crow Form from (Triggering unit)
        Unit - Turn collision for (Triggering unit) Off
        Unit - Pause (Triggering unit)
        Animation - Change (Triggering unit) flying height to 600.00 at 300.00
[B]        For each (Integer A) from 1 to 1000, do (Actions)
            Loop - Actions
                Wait 1.00 seconds[/B]
        Animation - Change (Triggering unit) flying height to 0.00 at 300.00
        Unit - Unpause (Triggering unit)
        Unit - Turn collision for (Triggering unit) On
        Unit - Order (Triggering unit) to Move To (Center of EndZone[((Player number of (Owner of (Triggering unit))) - 7)])

I just ran that and the unit came back to the ground unpaused and regained his collision after 1 second, its really weird.
 

vypur85

Hibernate
Reaction score
803
Code:
        For each [B](Integer A)[/B] from 1 to 1000, do (Actions)
            Loop - Actions
                Wait 1.00 seconds

It will wait 1000 seconds, providing that the Integer A is not interrupted. Try using a custom integer instead of the standard Integer A.

Code:
        For each [B]CustomVariable[/B] from 1 to 1000, do (Actions)
            Loop - Actions
                Game - Display to allplayers (CustomVariable) <-- Use this to check whether it's running or not
                Wait 1.00 seconds
This should work. But it may not be MUI in multiple casts. So try casting only once and see.
 

Beast

New Member
Reaction score
5
Haha I tried something like what you said he it just confused me more, but maybe this will help one of you. Heres what I ran

Code:
Catapult
    Events
        Unit - A unit Is attacked
    Conditions
        (Unit-type of (Attacking unit)) Equal to Catapult
    Actions
        Unit - Add Storm Crow Form to (Triggering unit)
        Unit - Remove Storm Crow Form from (Triggering unit)
        Unit - Turn collision for (Triggering unit) Off
        Unit - Pause (Triggering unit)
        Animation - Change (Triggering unit) flying height to 600.00 at 300.00
        For each (Integer A) from 1 to 1000, do (Actions)
            Loop - Actions
                Wait 1.00 seconds
                Game - Display to (All players) the text: (String((Integer A)))
        Animation - Change (Triggering unit) flying height to 0.00 at 300.00
        Unit - Unpause (Triggering unit)
        Unit - Turn collision for (Triggering unit) On
        Unit - Order (Triggering unit) to Move To (Center of EndZone[((Player number of (Owner of (Triggering unit))) - 7)])

when the trigger executed it worked fine up till the loop, then it displayed only the number 6, then did the rest of the trigger. Seems really random I have no idea whats happening.
 

Beast

New Member
Reaction score
5
OHHHHHHHH, I get it now. I tried it with a custom variable like you said and it works fine. I'm thinking there some other trigger that has a loop thats changing the value of integer A which this trigger is still executing. Meaning that even integer A and B are not locals! At least I'm pretty sure thats what it is.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top