The Dink Network

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.
Username:
Password:
Subject:
Antispam: Enter Dink Smallwood's last name (surname) below.
Formatting: :) :( ;( :P ;) :D >( : :s :O evil cat blood
Bold font Italic font hyperlink Code tags
Message:
 
 
February 15th 2012, 04:44 AM
anon.gif
shevek
Ghost They/Them
 
In "Karel ende Elegast", I have a simple save-system:
- there is only one save-game, no choice.
- the game auto-saves after any cut scene.

Now there are two special situation:
- when continue is attempted but no save file exists, there is a special cut-scene on the title.
- when continue is attempted but the game is already finished, there is a cut-scene on the title... but that's not detectable without actually loading the saved game...

So this is what I did to make it happen:
When finishing the game, Dink is moved to a special room. load_screen() is not called. The game is saved. Dink is moved to a different room (or I quit the game, not sure, you can check for yourself).

This means that during save, nothing special happens. But on loading that game, the main() of this special room is run. That room builds a screen which looks just like the title screen. It plays a cut-scene which is hardly distinguishable from the title, and then calls restart_game() to "continue" inside the title screen. The only visible effect is that the mouse pointer is lost during the cut-scene, and it is warped afterwards.

How can this help you? You can do something similar:
- Create a global variable real_room, or whatever you want to call it.
- On save, set real_room to the current map screen, move Dink to your special room, save, move him back to his current room. Don't call load_screen() at all.
- On load, Dink will be in the special room, its main() script gets run, you do what you want, including moving Dink to his real room. Here you do call load_screen() and draw_screen().

I didn't test it, but I'm pretty sure it should work.