Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Doctor Oakroot on Fri 21/09/2007 19:58:27

Title: Suggestion: Bullet proof PlayMusicQueued
Post by: Doctor Oakroot on Fri 21/09/2007 19:58:27
I've had some trouble in my games where a PlayMusicQueued executes with repeating music already playing... this causes the run-time to crash. Obviously you would never do this intentionally. It's happened in my games when the player does something unexplected but possible.

I can (and have) protect my script from it, but it would be nice if the AGS run-time would handle this more gracefully... by either treating it as PlayMusic or ignoring it. Either solution should be fairly easy to implement.

BTW, is there a way to detect whether repeating music is playing?
Title: Re: Suggestion: Bullet proof PlayMusicQueued
Post by: Radiant on Fri 21/09/2007 21:55:46
Quote from: Doctor Oakroot on Fri 21/09/2007 19:58:27
BTW, is there a way to detect whether repeating music is playing?


int __rep
function SetMusicRep1 (int repeat) {
  SetMusicRepeat (repeat);
  __rep = repeat;
}

function IsMusicRepeating () {
  return __rep;
}

Title: Re: Suggestion: Bullet proof PlayMusicQueued
Post by: Pumaman on Sat 22/09/2007 11:59:42
This sort of thing is a difficult one to call. If AGS just ignored it instead of showing the error message, then you'd get people posting "bugs" saying that their PlayMusicQueued wasn't working. I'm not sure if there's an ideal solution.
Title: Re: Suggestion: Bullet proof PlayMusicQueued
Post by: Doctor Oakroot on Sat 22/09/2007 23:02:13
That's true. What about an ability to turn off checking like with loop checking?
Title: Re: Suggestion: Bullet proof PlayMusicQueued
Post by: Pumaman on Sun 23/09/2007 13:26:42
Well, the easiest solution is probably to do what Radiant suggests and keep track of whether the music is repeating or not, and then check this variable before calling PlayMusicQueued if there's a situation where you're not sure what state the music might be in.
Title: Re: Suggestion: Bullet proof PlayMusicQueued
Post by: Doctor Oakroot on Sun 23/09/2007 15:58:43
That would certainly work if handled correctly (you would  have to actually queue music after using Radiant's code to set the repeat flag to know that repeating music was playing... and avoid clearing the flag without following it with a PlayMusic).

In my particular case, I know that if the player reaches certain rooms with music 207 still playing, I need to just start playing something else... I just added code to do that to the several rooms where the problem could occur.