The Dink Network

Wait command

August 10th 2009, 11:53 AM
wizardb.gif
Kyle
Peasant He/Him Belgium
 
Hard to search the forum for this, too many results :/

My question is pretty simple, what wait command equals a second? Previously I thought it was 1000, but I'm using a script right now that behaves differently when it comes to wait length... Just looking for some confirmation
August 10th 2009, 12:00 PM
pillbug.gif
pillbug
Peasant He/Him United States
Love! True love! 
From my DinkC Reference book:

void wait(int period);

wait will cause the current script to pause at least period milliseconds before continuing.


1000 milliseconds = 1 second, so...I dunno.
August 10th 2009, 12:01 PM
custom_skull.gif
Skull
Peasant He/Him Finland bloop
A Disembodied Sod 
I don't know what's the problem with your script. 1000 should mean a second.
August 10th 2009, 12:28 PM
wizardb.gif
Kyle
Peasant He/Him Belgium
 
I know, I have the book sitting right next to me too

But, do me a favor and try this:

void main (void)
{
int &timer = 500;
say("start", 1);
loop:
&timer -= 1;
wait(10);
if (&timer > 0)
{
goto loop;
}

say("done", 1);
kill_this_task();
}


This SHOULD take 5 seconds, but it takes a few seconds longer. (it's a spawned script)
August 10th 2009, 12:50 PM
bonca.gif
Erwin
Peasant He/Him Netherlands
Friendship is magic 
It takes time to run trough a script and you're doing that 500 times here so you'll notice it takes longer.
August 10th 2009, 12:51 PM
slimeg.gif
metatarasal
Bard He/Him Netherlands
I object 
I think this is because the execution of the script also takes time. (Given that your computer isn't infinitely fast) Try setting the wait to 100 and measure the deviation then to see if I'm right. (Haven't actually tested this)

This effect can be a bit of a pain in the ass for some functions. Usually one wait(1000); is better then 10 wait(100);'s...
August 10th 2009, 01:03 PM
wizardb.gif
Kyle
Peasant He/Him Belgium
 
You're right, if I do a wait(5000) it is (almost) exactly 5 seconds.

This is annoying It shouldn't take seconds to process scripts, even if it's 500 times. I suspect it's an inherent weakness in the coding, nothing I can do about it I guess I'll just make 2 scripts then and have one work with the full wait time.
August 10th 2009, 01:19 PM
slayer.gif
rabidwolf9
Peasant He/Him United States
twitch.tv/rabidwolf9 
It's fun to create manual lag like this though. Mess with someone's game and initiate this script and it'll annoy the heck out of them

void main ()
{
script_attach(1000);
int &crap;
loop:
&crap += 1;
if (&crap < 2500)
goto loop;
wait(500);
&crap = 0;
goto loop;
}
August 10th 2009, 06:30 PM
pq_water.gif
flood
Peasant He/Him New Zealand
 
it's because when the dink engine reads the "wait(period)" command it runs through all the other scripts that are active at the time before returning to the said script (but not before the "period" of time is up)

check this