Callback
I looked for it in the reference, but could not find it.
I need to know how a procedure is called after a few seconds, like when Dink is poisoned, and loses "life", or when Dink drinks water and after some time he wants to pee.
Thanks
I need to know how a procedure is called after a few seconds, like when Dink is poisoned, and loses "life", or when Dink drinks water and after some time he wants to pee.
Thanks
Pseudo code...
Somewhere:
//&spawned is global, you can also use any other valid check, just make sure it isn't run twice at the same moment, or you must want that.
if (&spawned == 0)
{
spawn("other_script");
//add .c extension?
&spawned == 1;
}
other_script:
void main( void )
{
wait(&loooong_time);
pee();
}
And the poison would be done with a loop and a timer or something.
other_script:
void main( void )
{
int &timer = 0;
loop:
wait(1000);
&timer += 1;
if (&timer == &time)
{
if (&poisoned != 1)
{
//Kill if not poisoned
kill_this_task();
}
&life -= 5;
}
goto loop;
}
Somewhere:
//&spawned is global, you can also use any other valid check, just make sure it isn't run twice at the same moment, or you must want that.
if (&spawned == 0)
{
spawn("other_script");
//add .c extension?
&spawned == 1;
}
other_script:
void main( void )
{
wait(&loooong_time);
pee();
}
And the poison would be done with a loop and a timer or something.
other_script:
void main( void )
{
int &timer = 0;
loop:
wait(1000);
&timer += 1;
if (&timer == &time)
{
if (&poisoned != 1)
{
//Kill if not poisoned
kill_this_task();
}
&life -= 5;
}
goto loop;
}
don't forget the script_attach(1000); if you are leaving the screen.
Nope, spawn(); makes it survive so you don't need script_attach(1000);
Also if you don't want Dink to pee (or whatever) when he's doing something else, there's the busy(); command. I've never tried, but it should work somewhere along these lines:
void pee()
{
hold:
int &busy = busy(1);
if (&busy != 0)
{
wait(500);
goto hold;
}
//pee here
}
void pee()
{
hold:
int &busy = busy(1);
if (&busy != 0)
{
wait(500);
goto hold;
}
//pee here
}