The Dink Network

Void die bugs.

June 20th 2011, 04:27 AM
duckdie.gif
Whenever I use the void die command, if I add more than 2 lines after it the D-Mod freezes and all Dink can do is stand like an idiot, breathing slowly. Can anyone help?

void die ( void)
{
freeze(1);
say_stop("Bla bla bla", 1);
unfreeze(1);
}
June 20th 2011, 04:50 AM
wizardb.gif
Kyle
Peasant He/Him Belgium
 
This is easy. The whole procedure won't run because the sprite is killed the next update and so the script stops, never getting to your unfreeze command.

You need to put that code into an external .c file and call that in the die() procedure. Like this:

void die ()
{
external("file");
}


and in that file you put your previous code under its void main().

Hope that helps
June 20th 2011, 04:53 AM
duckdie.gif
Oooh, thanks a bunch!
June 20th 2011, 04:54 AM
wizardb.gif
Kyle
Peasant He/Him Belgium
 
Anytime
June 20th 2011, 06:14 AM
slimeg.gif
metatarasal
Bard He/Him Netherlands
I object 
Don't forget to add: kill_this_task(); (This is needed because otherwise the script won't terminate and go on and use computer resources.)

So the full script would be:

void die(void)
{
freeze(1);
say_stop("Bla bla bla", 1);
unfreeze(1);
kill_this_task();
}
June 20th 2011, 07:53 AM
custom_magicman.gif
magicman
Peasant They/Them Netherlands duck
Mmmm, pizza. 
I have a write-up about this behaviour in this thread. The interesting part is:

- Dink kills monster
- Engine runs die() procedure, and makes sure that the sprite is killed whenever the engine has the chance to do something.
- die() procedure has one of the previously mentioned pausing commands. (
in this case say_stop)
- Engine pauses the script, and does something else.
- Engine chooses to kill the sprite.
- Engine kills sprite, and thus the script.
- Engine can no longer continue running the die() procedure.
June 20th 2011, 08:57 AM
wizardb.gif
Kyle
Peasant He/Him Belgium
 
Learning the ins and outs of this behaviour will allow any d-mod developer to write more complicated scripts, plus easily debug faulty scripts because this behaviour IS likely to sometimes cause you a headache