I trying to have it were you click on a swtich and the sound plays when it stops you go to the next room.
Bur right now it goes to soon.
// script for Object 0: Interact object
object[0].Animate(0, 5);
PlaySoundEx(12, 4);
Wait(120);
object[0].Visible = false;
character[GIRL].ChangeRoom(50, 100, 50);
Not sure what I'm doing wrong as I was just trying things to see if they would work or not.
Thanks for any help
get back later today when I wake up . been up all night and need some sleep.
How long is the sound?
By default Wait(120) waits for 3 seconds.
It's about 10 sec long.so I would have to add more or a way to make it wait till the sound ends?
Yes, you'll have to make the wait longer. If the track is 10 seconds, use Wait(400); or Wait(GetGameSpeed() * 10);.
However, since you're using PlaySoundEx() you could use IsChannelPlaying() in repeatedly_execute instead - it's more coding, but this way you won't have to work out the exact delay. You'll also need a variable, to check the sound has been started, something like:
// Main room script
int playing;
// script for Object 0: Interact object
object[0].Animate(0, 5);
PlaySoundEx(12, 4);
playing = 1;
object[0].Visible = false;
//repeatedly_execute
if (IsChannelPlaying(4)) Wait(1); // while track is playing, wait
else if (playing == 1) {
character[GIRL].ChangeRoom(50, 100, 50); // Track has stopped, so change room
playing = 0;
}
That should work OK.
Works perfect, thank you so much ..