Suggestion: Bullet proof PlayMusicQueued

Started by Doctor Oakroot, Fri 21/09/2007 19:58:27

Previous topic - Next topic

Doctor Oakroot

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?

Radiant

Quote from: Doctor Oakroot on Fri 21/09/2007 19:58:27
BTW, is there a way to detect whether repeating music is playing?

Code: ags

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

function IsMusicRepeating () {
  return __rep;
}


Pumaman

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.

Doctor Oakroot

That's true. What about an ability to turn off checking like with loop checking?

Pumaman

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.

Doctor Oakroot

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.

SMF spam blocked by CleanTalk