In Javascript (Node), I should run several expressions in an order and in some delays. This doesn't work because all of them run immediately, together in a mixed order;
var i = 0;
function run(){
console.log(i++);
};
setTimeout(run, 500);
setTimeout(run, 500);
setTimeout(run, 500);
setTimeout(run, 500);
And this is not good:
var i = 0;
function run(){
console.log(i++);
};
setTimeout(run, 500);
setTimeout(run, 1000);
setTimeout(run, 1500);
setTimeout(run, 1600);
Because It should stop evaluating the next expression. My program flow will go somewhere else and the function will run for no reason.
I need some synchronous functions to run with delay and in my written order. I couldn't implement it.
I don't know If I screwed up the design. I just want to make an online game clicking bot. But this is something different. This web bot should act like a human and click things with a random delay.
via Umut Ă–zdemir
No comments:
Post a Comment