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.
Complete #118: add the #randplay function