Script to run after loading save file

Hi,

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 ^_^


I 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
}

Thanks, 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...)


You could do it by override the InitUserInterface function in older versions.


Just tried out the user interface initialization script and it works perfectly for the music issue. So happy!


Is InitUserInterface gone in the new version?


Is 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>

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums