Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Bob The Hun on Tue 09/12/2003 03:52:34

Title: To make a Jukebox with PlayMusic, more complicated than i thought
Post by: Bob The Hun on Tue 09/12/2003 03:52:34
Agh, i've tried everything here, with still no luck.
I want to resume progress on my game, but I have one scripting problem that's holding me back. Most likely a minor scripting problem I'm not noticing, but I've tried everything I can think of, all to no avail.

I'm trying to make a jukebox sort of thing where the player can press a button and music will play. At first, it seemed simple enough.
I tried using hotspots, scripting it so that PlayMusic would play the appropriate song corresponding to the button. That didn't work, so I tried putting it in a GUI (where when a button was pressed the appropraite PlayMusic would be activated) and when I press a button, it would animate appropriately by temporarily going over to the other view, making it obvious that the button was being pressed properly, but there was still no change in the music. Then I read the manual some more and found a sentance saying that if PlayMusic was used in an interaction, you need to use PlaySound and add a thousand to the music number so that the engine would recognize it as music. I tried, and it still didn't work.
I've tried stopping the current music before the new music plays, still no luck.
And no, there is no default room music in the room where the jukebox is.

My current script is this:
If (interface == 11){
if (button == 0){
StopMusic();
PlayMusic (21);
}
if (button == 1){
StopMusic();
PlayMusic(22);
}
and so on..

So, what am I doing wrong here?
Title: Re:To make a Jukebox with PlayMusic, more complicated than i thought
Post by: Gilbert on Tue 09/12/2003 05:42:07
hmmm seems okay to me, did you name the music files properly to music21.xxx and music22.xxx ?

(where xxx is the extension for the music files, which can be mid, mod, mp3, ogg, etc.)
Title: Re:To make a Jukebox with PlayMusic, more complicated than i thought
Post by: Bob The Hun on Tue 09/12/2003 07:03:51
Double checked everything, and it's all right where it should be.
Names right and everything.
My computer must be being quirky, or something.
Title: Re:To make a Jukebox with PlayMusic, more complicated than i thought
Post by: Gilbert on Tue 09/12/2003 07:24:37
Put a:

Display("blah!");

line to one of the buttons' response to check if the codes are really executed correctly, eg.

If (interface == 11){
if (button == 0){
StopMusic();
PlayMusic (21);
Display("Blah!"); //add this for testing
}
if (button == 1){
StopMusic();
PlayMusic(22);
}

If the message is not displayed when you click on the button, there must be some problem with your interface_click function, check variable names, etc.
Title: Re:To make a Jukebox with PlayMusic, more complicated than i thought
Post by: RickJ on Tue 09/12/2003 10:12:04
Look in the GUI editor.  Make sure the button is setup to run a script.  It's interaction is probably set to NONE.
Title: Re:To make a Jukebox with PlayMusic, more complicated than i thought
Post by: a-v-o on Wed 10/12/2003 17:38:46
Are you sure that your music files aren't WAV files?

I tested it with hotspots and wav files won't play even when they are renamed to mid. I replaced the wav files with real mid files and all is fine.

No StopMusic command needed, only PlayMusic (21) and music21.mid is played.
Title: Re:To make a Jukebox with PlayMusic, more complicated than i thought
Post by: Bob The Hun on Fri 12/12/2003 04:20:25
Tried all of those, none of them worked. Checked all the scripts and everything, no luck.
But, just for the heck of it, I tried setting the GUI used in the jukebox to GUI 1 (which was empty anyway), I set everything up the same way, changed around all the room script to accomodate the different GUI, and oddly enough, everything works fine now.
Odd, but I got it to work, at least.