#randplay: play one sound out of a list
Some days ago you asked me to open a topic for using more sounds randomly for one single event.
I will describe it on an example:
Lets take the triggerline: "Stormtrooper is dead)
So lets say each stormtrooper is an individual beeing so every stormtrooper would make other sounds when it comes to leave the world.
And we have 5 soundfiles with differend screamings. Dead 1 to dead 5
It would be nice if you could use some kind of dead*.wav and cocomud would play one of the five files when the trigger fires.
Hope i could explain the scenario in an acceptable way!
Have a nice weekend!
#2 Updated by Vincent Le Goff almost 3 years ago
- Checklist item Add the #randsound sharp-script function added
- Checklist item Add the functions's user interface, allowing to add / remove sounds added
- Subject changed from More sounds for one trigger (random) to #randplay: play one sound out of a list
- Category set to SharpScript
- Assignee set to Vincent Le Goff
I propose to add the
#randplay sharp-script function. It could be used to add items to a list of random sounds. When called, it would play one of the sounds in the list.
#6 Updated by Vincent Le Goff 8 months ago
- Checklist item Add the functions's user interface, allowing to add / remove sounds set to Done
- Status changed from Open to Closed
- % Done changed from 50 to 100
Implemented in commit 9b9865b7a53b65afa3a1f9e60713c536b36dff4e . This is closer from what you had first requested, so I'll detail a bit here, waiting for a proper documentation about various SharpScript functions:
#randplay takes as argument a list of files, full or partial. It's easier to add this function through the SharpScript engine. For instance, go to Game -> Alias, click on Add, select a name, go to the list of actions, select "play a sound randomly", add the function. You will then be asked to specify the list. It's a simple text field. If you enter, for instance, the name
sound.ogg, then all the files called
sound.ogg will be searched recursively inside the folder of this world and one of them will be played randomly. Much more useful, however, you can specify a partial name, using the joker to specify "whatever": for instance, you could write
hit*.wav and all the files with
hit followed by something followed by
.wav will be selected and one of them will be played.
Farther still, you can specify several files separated by a semicolon. For instance,
sound1.ogg;sound2.ogg will play either file. Of course, you can specify partial names too:
hit*.wav;pain*.wav for instance.
Finally, you can ask CocoMUD to look in a specific directory instead of the world directory. To do that, just specify the directory name followed by the usual path separator before the file name (or match). For instance,
C:\Users\admin\sounds\hit*.ogg. CocoMUD will perform a search on your disk and if it's a directory with a lot of sub-directories, it might take some time. You can test CocoMUD's behavior on the specified search terms using the Test button.
Hope that sounds good! Thanks for the idea, it was excellent.
Please register to edit this issue