Author Topic: How do I make a while loop pause  (Read 474 times)

I need a while loop to wait 1 second between each time it runs, I tried
Code: [Select]
wait(1); but that didn't work, Anyone?

your best bet is just schedules that adds one second onto the time each iteration i think

edit:

ie

Code: [Select]
for(%i = 1; (statement); %i++)
{
//do stuff maybe
schedule(1000 * %i, 0, thingy);
}

function thingy()
{
//stuff you wanted to do
}
« Last Edit: December 31, 2011, 04:20:39 PM by otto-san »

Torque doesn't like to hang.  If it does, it will not let anything else run during that time, and that is a generally bad thing.

I hope I am using the term "hang" correctly.

Torque doesn't like to hang.  If it does, it will not let anything else run during that time, and that is a generally bad thing.

I hope I am using the term "hang" correctly.
The proper term is deadlock.


try making a new function with schedules with an if inside for stopping?
sorta like
Code: [Select]
$stop = 0;
function quack()
{
  if($stop == 1)
    return;
  commandtoserver('messagesent', "quack");
  schedule(1000, 0, quack);
}
set $stop to 1 to stop,
or
Code: [Select]
function quack()
{
  cancel($quack);
  commandtoserver('messagesent', "quack");
  $quack = schedule(1000, 0, quack);
}
and use cancel($quack) to stop