Posted by
| Nick Gammon
Australia (23,042 posts) bio
Forum Administrator |
Message
| After a few requests for MSP, I am pleased to present a way of handling MSP in the existing version of MUSHclient, which should be acceptable for players wishing to hear sounds, before MSP is integrated into MUSHclient itself.
It involves setting up a single trigger, which matches on a MSP line. The trigger calls a script, which plays the appropriate file.
Here is an example of an MSP line, from the Dawn Of Time codebase ...
!!SOUND(action/huh.wav V=75 L=1 P=50 T=action U=http://www.stormbringer.sytes.net/msp/action/huh.wav)Huh?
This is sent when the player makes a typing mistake. It plays the file "huh.wav" and sends "Huh?" to the player.
The problem with making a trigger to match sounds is that the !!SOUND directive might be preceded by, and followed by, text the player is supposed to see, so we have to make a trigger that returns 3 wildcards:
- The text before the sound
- The sound file name
- The text after the sound
For example:
text-before !!SOUND(action/huh.wav V=75 L=1 P=50) text-after
The parts in bold will be the three wildcards.
Below are the steps for getting MSP to work for you ...
1. Add the following script to your script file (VBscript)
'
' Trigger script to simulate MSP (MUD Sound Protocol)
'
sub OnSound (strName, strLine, aryWildcards)
dim sBefore, sSound, sAfter, iColourFore, iColourBack
' extract text from wildcards
' wildcard 1 is the text before the sound
' wildcard 2 is the sound file name
' wildcard 3 is the text after the sound
sBefore = aryWildcards (1) ' what arrived before the !!SOUND directive
sSound = replace (aryWildcards (2), "/", "\") ' sound file to play
sAfter = aryWildcards (3) ' what arrived after the !!SOUND directive
' play sound - AMEND DIRECTORY as required
world.Sound ("c:\mushclient\msp\" & sSound)
' remember current world.note colours
iColourFore = world.notecolourfore
iColourBack = world.notecolourback
' set note colour to default text colour
world.NoteColourRGB world.NormalColour (8), world.NormalColour (1)
' display the text surrounding the sound
world.note sBefore & sAfter
' set note colour back to what it was
world.NoteColourRGB iColourFore, iColourBack
end sub
2. Add a trigger
Trigger: ^(.*)\!\!SOUND\(([A-Za-z0-9./]+).*\)(.*)$
Regular expression: checked
Omit from output: checked
Label: sound
Script: OnSound
3. Get the sound files
This technique does not automatically download sound files like some other client programs do. However most MUDs that support MSP will supply all their sound files as a single "zipped" file. If not, ask their admins nicely for one, I'm sure they will be happy to oblige.
Download that file, and then put your sounds in a subdirectory "msp" below the MUSHclient install directory.
If you put them somewhere else (eg. in a directory per world) then amend then
script above to reflect the location of the sound files.
In my example, if MUSHclient was installed into C:\MUSHclient, then the "huh" sound might be in:
c:\MUSHclient\msp\action\huh.wav
4. Enable MSP
MSP has a telnet negotiation sequence which lets the server auto-detect whether the client supports MSP. However some servers, at least, let you turn MSP on manually (eg. Dawn Of Time).
Type in whatever command you need to enable MSP, eg.
msp on
5. Test
Now you should be ready to test. Type in whatever is needed to trigger a sound (eg. a nonsense command in Dawn Of Time) and listen to see if the sound is played.
Limitations
This method is not a full implementation of MSP, however it should get you up and running with sounds if that is what you want.
Here are some limitations of it ...
- Sounds are not automatically downloaded, you must get the sound files manually (this should not be a big deal, it just means you have to download one big file and unzip it).
- MSP parameters such as sound volume are ignored, so all sounds will play at the same volume
- Multiple sounds will not play simultaneously
- In order to stop the !!SOUND text from displaying the whole matching line is omitted from output. The script uses world.note to display any other text (eg. "Huh?") however that will be displayed in the default text colour. Any colouring of the line that the server had put there will be discarded.
- There is no telnet negotiation, so some servers might not send down the !!SOUND lines, unless you can turn MSP on manually.
Having said all that, it seems to work fine on the DOT servers, so if you want to try MSP in MUSHclient, give it a go! :)
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|