The Dink Network

Timer

September 26th 2008, 08:07 AM
anon.gif
?
Ghost They/Them
 
I've got a problem with Sparrowhawk's Timer. How can I stop the timer? I have a not-ready script here:

void hit( void )
{
Playsound(52,22050,0,0,0);
fade_down();
}


Now I would like to know what must I put here to make the timer stop running.

Thanks, Mystery...
September 26th 2008, 10:12 AM
slimeg.gif
metatarasal
Bard He/Him Netherlands
I object 
Please post a question on a specific file in the file discussion for that file in the future. And about your problem:

First define a new global variable by adding this line in main.c:

make_global_int("&varry", 0);
(I'm using the variable name &varry for this example...)

Next, do this in timer.c (Sparrow's file):

Replace this line:
//if (&your_var == whatever) goto done;
with:
if (&varry == 1)
{
goto done;
}

Finally, in the script you posted add the line:
&varry = 1;
September 26th 2008, 10:16 AM
dinkdead.gif
You'll need a global variable, so in main.c add:
make_global_int("&yourname", 0);

Call it what you like. When you start the timer, instead of just doing spawn("timer"); do this
&yourname = spawn("timer");

Then to stop it, add one of these lines anywhere in your script:
run_script_by_number(&yourname, "stoptheclock");
will kill the timer but leave the (stopped) time drawn to the screen.
run_script_by_number(&yourname, "kill");
will stop the timer and kill the displayed time.

Nice to know someone's using it

Edit: I was writing this at the same time as Metatarasal
His way is probably what you meant, I wasn't thinking. My way will just kill the timer off.

I mean, use my way if you just want to stop and get rid of the timer.
Use Metatarasal's way if you want something to happen when the timer stops, for example if you have to hit this thing before the time runs out. Put what you want to happen in the right place in timer.c.