Reply to Re: What's the best way to run a script every time a save is loaded?
If you don't have an account, just leave the password field blank.
I think I must have made that "complication" sound worse than it is. The only thing that happens that is main.c dies when it gets to a wait() or equivalent. Any scripts it has spawned "keep running" as normal (which is what I meant to say, that was a confusing turn of phrase though, I admit).
So what I using right now:
In case you're wondering, the only reason fade_up is even there is as a safety precaution against the screen staying black if somebody loads new game while faded down.
That deal where main.c dies at a wait does make me a little uneasy, but as far as I can tell, this works perfectly. Actually this is a little more complicated than it needs to be, I could have done without loadgame.c, but I wanted to keep things tidy in case I had a bunch more stuff that needs to happen on load.
So what I using right now:
//main.c run when dink is started void main() { make_global_int("&exp",0); make_global_int("&strength", 1); make_global_int("&defense", 0); //blah blah blah // Some Dink 1.08 enhancements. Not required, but so much nicer. set_smooth_follow(1); // Helper script for loading a save game. spawn("loadgame"); // Note: fade_up() has a deley, so main.c will die here if we loaded a game. // That's why I moved it way down to the bottom. fade_up(); kill_this_task(); }
In case you're wondering, the only reason fade_up is even there is as a safety precaution against the screen staying black if somebody loads new game while faded down.
//loadgame.c is launched from main.c void main ( void ) { if (&player_map == 0) kill_this_task(); //Obviously we're not loading a game, bye bye. //Note: Nothing weird happens here -> wait(1); // Launch Status Script // And this was my main goal, a script that puts some extra info on the status bar using noclip sprites. spawn("status"); kill_this_task(); }
That deal where main.c dies at a wait does make me a little uneasy, but as far as I can tell, this works perfectly. Actually this is a little more complicated than it needs to be, I could have done without loadgame.c, but I wanted to keep things tidy in case I had a bunch more stuff that needs to happen on load.