MSP issue due to Directory name

Posted by Saerataga on Wed 30 Jul 2014 05:38 PM — 13 posts, 50,048 views.

#0
Hi Nick,

I have a suggestion. I think most other mud clients use sound directory for MSP, and you have mushclient using sounds directory. While not a huge deal for most, I have blind players. They could not figure it out. I had to download Mushclient and wine to get it to work myself. Which is when I noticed the folders are differently named. That said, I would like to suggest sounds folder be named sound for the installation of mushclient.

Thanks for your time and hardwork!
Amended on Wed 30 Jul 2014 06:08 PM by Saerataga
Australia Forum Administrator #1
I'm reluctant to change that now as lots of people will have designed their plugins to expect sounds in "sounds" and not "sound".

However as a work-around you could suggest that players install the following plugin:

Template:saveplugin=Sound_File_Redirector
To save and install the Sound_File_Redirector plugin do this:
  1. Copy the code below (in the code box) to the Clipboard
  2. Open a text editor (such as Notepad) and paste the plugin code into it
  3. Save to disk on your PC, preferably in your plugins directory, as Sound_File_Redirector.xml
    • The "plugins" directory is usually under the "worlds" directory inside where you installed MUSHclient.
  4. Go to the MUSHclient File menu -> Plugins
  5. Click "Add"
  6. Choose the file Sound_File_Redirector.xml (which you just saved in step 3) as a plugin
  7. Click "Close"
  8. Save your world file, so that the plugin loads next time you open it.


This catches attempts to play sounds with no pathname, and plays them from the "sound" folder rather than the "sounds" folder.


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>

<muclient>
<plugin
   name="Sound_File_Redirector"
   author="Nick Gammon"
   id="2322e8bf7085dbeab87759b4"
   language="Lua"
   purpose="Plays sounds from &quot;sound&quot; directory"
   date_written="2014-07-31 07:09:23"
   requires="4.80"
   version="1.0"
   >

</plugin>

<!--  Script  -->

<script>
<![CDATA[
function OnPluginPlaySound (s)
  if string.match (s, "^%a:\\") then  -- see if s began with a drive letter
      Sound (s)                           -- so play s without prepending anything to it
    else
      Sound (GetInfo(66) .. "sound\\" .. s)
    end -- if
end -- OnPluginPlaySound 

]]>
</script>

</muclient>


This could be distributed along with whatever .zip file you have for the MUD's sounds. Alternatively just have a different sound distribution for MUSHclient (eg. say "download A for MUSHclient and B for other clients") for example, along with a brief explanation.
Australia Forum Administrator #2
On this page:

https://www.zuggsoft.com/zmud/msp.htm

There is no clear direction about the name of the sound folder. The various examples (for the download URLs) use "sounds" and not "sound", eg.


!!SOUND(Off U=http://www.example.org:5000/sounds)





On this page:

http://tintin.sourceforge.net/scripts/msp.php

It says:

Quote:

For this script to work the MUD needs to support MSP (Mud Sound Protocol), you must have the right audio files in the /~sounds directory (directory can be changed in the script), and you must be able to play sound files.


My emphasis.

So I'm not sure I agree that other clients always expect "sound" rather than "sounds".




On this page:

http://archive.today/rrEKq

It says:

Quote:

The !!MUSIC spec is implemented as a general Windows MCI device in zMUD. Thus, any valid MCI file may be played with this command. For example, you can play an AVI file using the string:
!!MUSIC(goodtime.avi)
assuming that goodtime.avi is located in the sounds subdirectory of your settings folder Any MCI device supported by windows can be played, including wav, mdi, rmi, avi. There are also plugins available on the net for playing .mod files.


My emphasis again. Thus you can see why I made the sound folder be named "sounds".
Amended on Wed 30 Jul 2014 08:32 PM by Nick Gammon
#3
Added plugin Z:\home\saerataga\Downloads\MUSHclient\worlds\plugins\sound_redirect.xml
kill skeleton

Trigger function "OnSound" not found or had a previous error.
Your massive maw **** SMITES **** a skeleton 4 times for 436 total damage!
You receive 35 experience points.
A skeleton is DEAD!!
You receive 46 experience points.
Trigger function "OnSound" not found or had a previous error.

No luck so far Nick. Maybe I was dead wrong and the folder being named sound instead of sounds has no bearing. It looks like it is the function onsound that is the only issue.
Amended on Sat 09 Aug 2014 03:37 PM by Saerataga
Australia Forum Administrator #4
Can you paste your trigger please?

Template:copying
For advice on how to copy aliases, timers or triggers from within MUSHclient, and paste them into a forum message, please see Copying XML.


And the place where you have OnSound? (the script).
#5
Nick the trigger as in game code !!SOUND or as a client side? I don't have any client side triggers, I just was trying to use MSP with the client.

The OnSound script location? I looked I can't find it anywhere. Doesn't help that I am using wine and Unbuntu to try this, but I don't have access to a windows computer.

Sorry I don't think I answered a single question you asked, but I don't know the answers. This is the lastest Mushclient download run with wine. The only plugins I have are msp and soundredirect that you gave me.
Australia Forum Administrator #6
Hmm, OK I see.

That plugin is pretty old and requires VBscript which maybe didn't work for you. I have reworked it in Lua which should work better under Wine.

Template:saveplugin=MSP_Lua
To save and install the MSP_Lua plugin do this:
  1. Copy the code below (in the code box) to the Clipboard
  2. Open a text editor (such as Notepad) and paste the plugin code into it
  3. Save to disk on your PC, preferably in your plugins directory, as MSP_Lua.xml
    • The "plugins" directory is usually under the "worlds" directory inside where you installed MUSHclient.
  4. Go to the MUSHclient File menu -> Plugins
  5. Click "Add"
  6. Choose the file MSP_Lua.xml (which you just saved in step 3) as a plugin
  7. Click "Close"
  8. Save your world file, so that the plugin loads next time you open it.



<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE muclient>

<muclient>
<plugin
   name="MSP_Lua"
   author="Nick Gammon"
   id="7da63d78d9f91bebb5285127"
   language="Lua"
   purpose="Emulates MSP (MUD Sound Protocol)"
   save_state="y"
   date_written="2014-08-10 15:43"
   requires="4.54"
   version="1.0"
   >
<description trim="y">
<![CDATA[
Type: "msp:help" to see this help.

See: http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=783 for a more complete description.

You will need to get the sound files manually (ie. from the MUD) and install them before using this. 
The plugin is configured to look for them in the "sounds" directory of the MUSHclient installation,
but you can change that by typing:

  set_msp_path new_path

eg.

  set_msp_path d:\muds\mushclient\msp

]]>

</description>

</plugin>


<!--  Triggers  -->

<triggers>
  <trigger
   enabled="y"
   match="!!SOUND\(([A-Za-z0-9./]+).*\)"
   name="sound"
   omit_from_output="y"
   regexp="y"
   script="OnSound"
   sequence="100"
  >
  </trigger>
</triggers>

<!--  Aliases  -->

<aliases>
  <alias
   script="On_set_MSP_path"
   match="set_msp_path *"
   enabled="y"
  >
  </alias>
  
  <alias
   script="OnHelp"
   match="msp:help"
   enabled="y"
  >
  </alias>

</aliases>

<!--  Script  -->

<script>
<![CDATA[

function fSound (filename)
  PlaySound (0, GetVariable ("msp_path") .. filename)
  return "" -- omit MSP stuff from output
end -- function fSound

-- handle a line with !!SOUND in it
function OnSound (name, line, wildcards, styles) 

	-- echo existing line with colours, sending !!SOUND part to a function
  for _, v in ipairs (styles) do
    local text = string.gsub (v.text, "!!SOUND%(([%a%d./]+).-%)", fSound)
    ColourTell (RGBColourToName (v.textcolour), 
                  RGBColourToName (v.backcolour), 
                  text)  
  end -- for each style run

  Note ("") -- finish the line
end -- function OnSound

-- change desired sound file path
function On_set_MSP_path (name, line, wildcards) 
  local path =  wildcards [1]
  
  --  ensure trailing backslash
  if string.sub (path, -1) ~= "\\" then
     path = path .. "\\"
  end -- if

  SetVariable ("msp_path", path) 
  print ("MSP sound files will be obtained from " .. path)
end -- function On_set_MSP_path

-- do telnet negotiation
function OnPluginTelnetRequest (type, data)
  if type == 90 and data == "WILL" then
    return true -- IAC DO MSP
  else
    return false
  end -- if
end -- function OnPluginTelnetRequest

-- show help
function OnHelp ()
  print (GetPluginInfo (GetPluginID (), 3))
end -- function OnHelp

-- use supplied path or default
msp_path = GetVariable ("msp_path") or GetInfo (74)

]]>
</script> 

</muclient>


The default path in the old plugin was c:\mushclient\msp which was probably not where you had your sound files.

This version has a few improvements. For one thing the default path is now the "sounds" directory in the MUSHclient installation, wherever that is. You can change that with the "set_msp_path" alias, eg.


set_msp_path c:\Program Files\MUSHclient\sound


This plugin should better handle coloured text from the MUD, as it preserves colours, which the old one didn't.

It also handles multiple sounds on one line (I don't know if that is common or not).

It also handles multiple sounds playing at once (up to 10) which might happen in combat.

Finally, it does telnet negotiation for MSP, which could help.

See how that goes.
Amended on Sun 10 Aug 2014 05:41 AM by Nick Gammon
#7
Thanks for the lua script, I think your right vb isn't doing well with wine. I don't get any errors now, just no sound.

I used

set_msp_path Z:\home\saerataga\Downloads\MUSHclient\sounds

I don't really need this to work for myself with linux. The players I have use windows with mushclient. But they can't get it to work. I'll post my help file for mushclient and with the new lua plugin you gave me, and if you see something wrong with the instructions I'll try that.

help mushclient


Directions to implement MSP (Mud Sound Protocol) on MUSHclient.

1. Download all the sound files that you want.
https://www.dropbox.com/s/9mzzbntbrte6w8a/Battle.zip
https://www.dropbox.com/s/onr8rnmi1e1ptmp/Communication.zip
https://www.dropbox.com/s/vnxwh8vxpfqxx6h/Music.zip
https://www.dropbox.com/s/4xdaoawr4epr2hl/Tradeskills.zip
All 4 in one included in sound.zip
https://www.dropbox.com/s/bxn3vo65sr7qsz8/sound.zip

take note of where you save them too.

Download this updated Lua MSP plugin https://www.dropbox.com/s/5fs6j0388i64ny0/MSP_Lua.xml
Put in your MUSHclient\world\plugins

2. Start up the Mushclient and click on File
3. Next click on Plugins
4. Find MSP_Lua.xml and click on it hitting the add button.
5. Make sure you also click on the enable button before closing.
6. Unzip the sound.zip files into MushClient directory.
7. Delete sounds directory and rename sound directory to sounds
8. In the mud type "config sound"

If that doesn't do it you can try typing this on the mushclient itself.
set_msp_path C:\MUSHclient\sounds
Then type config sound mush
Restart MUSHclient

Note: MUSHclient 4.86
It is recommended that you install this in C:\MUSHclient - some players
have reported problems when running in C:\Program Files\MUSHclient,
particularly with Windows 7.
Amended on Sun 10 Aug 2014 11:18 AM by Saerataga
Australia Forum Administrator #8
First, let's check it plays the files OK. It did for me BTW.

If you put the sounds as you described, eg.


C:\Program Files\MUSHclient\sound\Battle\backstab1.wav


Then in the Immediate scripting window (Ctrl+I) and assuming you are using Lua (the default) try this:


PlaySound (0, "../sound/Battle/backstab1.wav")


That goes up out of "sounds" and down into "sound/Battle" and then plays the sound.

Now if that works, we need to look at the MSP stuff. If not, we need to find why not.

Can you post a line or two of example sounds? That is, turn the MSP plugin off, and show me what the MUD sends, eg,


Testing !!SOUND(Battle/backstab1.wav V=75 L=1 P=50 T=action U=http://whatever/Battle/backstab1.wav) Foo Bar
#9
I don't use other directories as of yet. eg battle, communication, etc yet.

I just have them put what ones they want in the sound directory.

PlaySound (0, "../sounds/backstab1.wav") This worked in the intermediate but not any other time.

Here's a trigger example with msp off

!!SOUND(sound/miss.wav)

!!SOUND(sound/ooc.wav)
Amended on Mon 11 Aug 2014 01:16 AM by Saerataga
Australia Forum Administrator #10
OK, I think your instructions are a bit out. If you change the fSound function inside the plugin to report errors like this:



function fSound (filename)
  local result = PlaySound (0, GetVariable ("msp_path") .. filename)
  if result ~= error_code.eOK then
    ColourNote ("red", "", "ERROR: " .. error_desc [result] .. " playing " .. GetVariable ("msp_path") .. filename)
  end -- if
  return "" -- omit MSP stuff from output
end -- function fSound


Now testing with the "sound" directory I get this:


ERROR: Cannot open the specified file playing c:\program files\mushclient\sound\sound/miss.wav


As you can see the directory "sound" is there twice because you made it be the sound path:

Saerataga said:

If that doesn't do it you can try typing this on the mushclient itself.

set_msp_path C:\MUSHclient\sounds



But the sub-folder "sound" is in the !!SOUND from the MUD, so you have it twice.

It works if you set the MSP path:


set_msp_path C:\MUSHclient


Or just get them to name the folder "sounds" rather than "sound" then it becomes the default sound folder. It works, you have proved that, you just have to get the pathname right.
Amended on Mon 11 Aug 2014 08:43 AM by Nick Gammon
Australia Forum Administrator #11
Actually I take that last bit back. Get them to put the "sound" folder from the download inside "sounds" which already exists in the MUSHclient installation. Then it will find the right pathname:


<install dir>/sounds/sound/miss.wav


Where the bold part is from the !!SOUND trigger and the rest is the default sound directory.
#12
Thanks Nick that works Perfectly!

If anyone is curious this is MUSHclient working without bugs. Using Linux Latest Unbuntu 14.04 and latest wine download. Btw you can't do that with zmud, works but buggy with wine.