Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Delaying your script a few seconds....

1367806041
Konrad J.
Pro
API Scripter
I've got a script that moves a token an inch forward and half an inch to the right or left.  Its a maneuver in Car Wars.  If anyone could point me in the right direction, I would like to put a slight pause inbetween the two moves so that the user can see it happen, whats the best way to do this?  I'm looking at Statechange right now, just need to figure it out. Thanks,
In Javascript you can delay an action, but it has to be asynchronously done. For example, you can do: action1(); setTimeout(function() {     action2(); }, 1000); //1000ms = 1 second, change this to the delay you want
1367858727
Konrad J.
Pro
API Scripter
Riley D. said: In Javascript you can delay an action, but it has to be asynchronously done. For example, you can do: action1(); setTimeout(function() {     action2(); }, 1000); //1000ms = 1 second, change this to the delay you want That was simple!  And it worked great, now the user can see the car move while its doing its maneuvers. :)