looping music for soundpacks

Posted by Musicmyxtress on Wed 12 May 2021 01:53 AM — 6 posts, 23,357 views.

#0
Hi everyone,
So I want to start making my own soundpacks for muds. I'm good with triggers and aliases and timers, but never really gotten into scripting much. Still I have learned how to play a sound that loops, but I have one last problem and I've never found script examples to look at. I play a mud where there are different room types. what I want to do is make ambiences for each one. In the room desc it says the type on its own line, for instance, jungle biome. I'd like to make it loop a jungle sound when it's a jungle biome, but keep looping if youo walk into another jungle, but change if you go into another type. I know this can be done because it has been done in other muds, but in those I can't for the life of me find their scripts.
If anyone can give any advice on this, I'd be forever greatful.
Australia Forum Administrator #1
Well, you store (remember) the room type, and when you change rooms see if the new room type is the same as the old room type. If so, do nothing. If not, change the music, and store the new room type.
#2
Ok, thanks. what I'm still struggling with is where you would do that. It's a specific line in every room. I'm not sure how I would tell it to get that line and store it. Would I, as I originally thought, make a different trigger for each biome type? or do I have to write a script file with some empty variable and then somehow recognize that line as the one to update it? Apologies for my newbieness.
USA Global Moderator #3
Quote:
Would I, as I originally thought, make a different trigger for each biome type?

If you want, sure. Or if the lines are all sufficiently similar maybe you could use one trigger with a wildcard capture.
Amended on Wed 12 May 2021 01:59 PM by Fiendish
Australia Forum Administrator #4
You would use a trigger with a wildcard as Fiendish suggested, or one trigger per different room if necessary.

Something like this:


<triggers>
  <trigger
   enabled="y"
   match="You enter the jungle."
   send_to="12"
   sequence="100"
  >
  <send>
  changeBackgroundMusic ('jungle') -- see if music needs to change
  </send>

  </trigger>
</triggers>



Template:pasting
For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.


That trigger calls a shared function changeBackgroundMusic passing it the type of the current biome.

The script file (set that up in the Scripting configuration tab) could consist of something like this:



function changeBackgroundMusic (newBiomeType)

  -- change background music if the biome type changes
  if newBiomeType ~= oldBiomeType then
    PlaySound(1, newBiomeType .. ".wav", true)  -- play sound, looping
    oldBiomeType = newBiomeType
  end -- if

end -- changeBackgroundMusic


So in this case the sound files would be "jungle.wav" for the jungle biome, and so on.
Amended on Thu 13 May 2021 05:25 AM by Nick Gammon
#5
Thank you, I've bookmarked this so i can try to learn how to use it. This will definitly help.