Script to run after loading save file

Amadea
09 Feb 2018, 16:55Hi,
I'm working on a game with music (as a matter of fact something is almost always playing). One challenge that I'm experiencing right now is that when the player loads a saved game they will start out with silence until they enter a part of the game where music will be activated again. The song that should be playing is often indicated by a flag. I am wondering if there is any way to make a certain script run when a saved game is loaded. My idea is that this script will check for the appropriate flag and play the corresponding song.
Disclaimer: I mostly use the graphical editor (offline version). I have a little experience with programming and know how to access the "code view" for the game, but if any explanations can be kept relatively simple I would appreciate it ^_^
The Pixie
09 Feb 2018, 17:10I was looking at this myself recently. Go to the Features tab of the game object, and tick the "Advanced scripts" box, then go to the Advanced scripts tab. The script at the top is really for setting up the UI but can be used for what you want. The trick is to test if this is the start of the game or not, which you can do by seeing if game.pov
is null.
if (not game.pov = null) {
// Do your stuff
}

Amadea
09 Feb 2018, 17:18Thanks, I will give this a try (this means I have to finally update Quest, since the older version of quest doesn't have the advanced scripts option...)
The Pixie
09 Feb 2018, 20:45You could do it by override the InitUserInterface
function in older versions.

Amadea
09 Feb 2018, 20:48Just tried out the user interface initialization script and it works perfectly for the music issue. So happy!
Pertex
10 Feb 2018, 22:25Is InitUserInterface gone in the new version?

K.V.
10 Feb 2018, 23:19Is InitUserInterface gone in the new version?
It's still there.
The last two bits of InitInterface()
call it, along with game.inituserinterface
if it has a script.
<function name="InitInterface"><![CDATA[
//This is just the last 4 lines
InitUserInterface
if (HasScript(game, "inituserinterface")) {
do (game, "inituserinterface")
}
]]></function>
<function name="InitUserInterface">
</function>