Castle Paradox Forum Index Castle Paradox

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Gamelist   Review List   Song List   All Journals   Site Stats   Search Gamelist   IRC Chat Room

Stopping Music for Sfx?

 
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP!
View previous topic :: View next topic  
Author Message
emmychu
I choose you!




Joined: 12 Apr 2013
Posts: 3

PostPosted: Sat Apr 13, 2013 6:20 am    Post subject: Stopping Music for Sfx? Reply with quote

Been here only a short while and I'm already blasting questions everywhere. XD

Anyway, this seems like a very simple thing and yet I can't quite seem to figure it out. I've got a cutscene going with plotscripting, and I need a sound effect to play at a certain text box. The effect is a little tune that lasts for a few seconds, and I want the music to stop playing for the duration of it.

I can stop the song and play the sound effect, but I don't know how to replay the map music after the sound effect is finished. I could always figure out a wait command for the duration of the effect, but I want the player to be able to advance text boxes while the effect is playing...

How do I make it so the map song plays after a sound effect is done, while still advancing the script in that time? D:
Back to top
View user's profile Send private message
Bob the Hamster
OHRRPGCE Developer




Joined: 22 Feb 2003
Posts: 2526
Location: Hamster Republic (Southern California Enclave)

PostPosted: Sat Apr 13, 2013 9:16 am    Post subject: Reply with quote

Hello, emmychu! Welcome!

Try something like this:

Code:

plotscript, example, begin
  stop song
  play sound(1)
  wait(30)
  play song(get ambient music)
end
Back to top
View user's profile Send private message Send e-mail Visit poster's website
sotrain515




Joined: 17 May 2010
Posts: 39
Location: Connecticut

PostPosted: Mon Apr 15, 2013 12:14 pm    Post subject: Reply with quote

Hmm, seems that emmy is looking for something a little more complex. I think the way you want to do this is through timers.. though I've never used them myself, I'll take a stab at a solution.

Let's say this was your original code (by the way, it can often be helpful to us, your would-be helpers, if we could see the code you are currently working with):
Code:

script, main script, begin
...
   stop song
   play sound(1)
   show text box(1)
   wait for text box
   show text box(2)
   wait for text box
...
   play song(get ambient music)
...
end


So you would be resuming the map music arbitrarily after X text boxes. Or you could do it the way James suggests, which would wrest control from the user while the sound effect plays and then return it (and restore the ambient music) when it was finished. The way I think you want to do it is with a timer.

Here is the timer script:
Code:

script, timer resume ambient music, timer, begin
   play song(get ambient music)
   stop timer(timer)
end


And here is how your code (aka the code I just wrote at the top) would be changed:
Code:

script, main script, begin
...
   stop song
   play sound(1)
   set timer(0, 30, 1, @timer resume ambient music, 0, timer flag: menu)
   show text box(1)
   wait for text box
   show text box(2)
   wait for text box
...
end


That "30" in the set timer call is assuming that your sound is 30 ticks long (as James did)... or maybe "around 30" would be better to say, since timers apparently start counting down after the current tick. In other words, you will likely have to do some tweaking with that value based on playtesting.

Now, I said it at the top, but I'll just reiterate that I have never actually used timers in any of my scripts, so this is largely theoretical to me. I believe this should give you the desired effect of the music coming back whenever the sound effect is done, though.

e: Play song/stop song, not suspend/resume map music....
Back to top
View user's profile Send private message Send e-mail
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Mon Apr 15, 2013 8:52 pm    Post subject: Reply with quote

Yes, if you have no other scripts running, then the script James posted would work fine, but a scripted cutscene was mentioned. Timers are a solution.

By the way, there's no need to put a "stop timer" command in a script that is triggered by a timer: a timer only triggers once, so it's already stopped at that point (though it remembers most of its settings).

Also, be warned that "play song(get ambient music)" won't work if the map is set to the same music as the previous map.
_________________
"It is so great it is insanely great."
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP! All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group