Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: KiraHaraReturns on Sat 09/03/2013 18:52:46

Title: Musicbox
Post by: KiraHaraReturns on Sat 09/03/2013 18:52:46
I would like to make my game play music tracks controlled by score. It means, the player collects point for doing something and if the number of points reaches some value, the music track should be changed immediately. Does anyone have an idea how to solve it?
Title: Re: Musicbox
Post by: Khris on Sat 09/03/2013 19:56:22
Provided you're using the GiveScore() function, you can use this (add it to GlobalScript.asc):

Code (ags) Select
function on_event (EventType event, int data) {
  if (event == eEventGotScore) {
    if (game.score >= 50 && Game.DoOnceOnly("reached 50 points")) {
      // change music here
    }
  }
}
Title: Re: Musicbox
Post by: KiraHaraReturns on Sat 09/03/2013 20:47:55
it works, thank you very much