[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Plugins
. . -> [Subject]  suggestion for a useful plugin

suggestion for a useful plugin

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Rashan2   USA  (3 posts)  [Biography] bio
Date Sun 21 Jul 2002 12:33 AM (UTC)
Message
For those looking for suggestions for plugins that would be kind of a general set of scripts that could be useful on just about any type of MU*, I'd like to suggest a decompilier plugin.

Essentially, the plugin would get a list of all the objects that a player owns on the MU*, and then @decom each object into a different .txt file all dumped into a directory. It would probably need to be done in such a way that the output of the decompile doesn't exceede the overflow buffer of the MU*.

Just tossin out the idea. :)


Rashan
[Go to top] top

Posted by Xeryus   (2 posts)  [Biography] bio
Date Reply #1 on Fri 09 Aug 2002 02:13 AM (UTC)

Amended on Fri 09 Aug 2002 02:15 AM (UTC) by Xeryus

Message
I think a plugin to give MSP (Mud Sound Protocol) would be an excellent plugin. Since I see requests as far back as three and a half years ago to add MSP and it is still not implamented.

Its easy to get a specific sound to play with a script, but to have it download the sound AND play it is what I require and I am sure others do to. Not all muds have released the sound packs in a ZIP format... unfortunately... I hate going to a new area in a game, seeing the MSP tag for a new WAV file and having to interrupt my mudding to go get it manually.

Thanks
Xeryus
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Fri 09 Aug 2002 03:06 AM (UTC)

Amended on Fri 09 Aug 2002 04:35 AM (UTC) by Nick Gammon

Message
Good idea. I have adapted my suggested idea in the forum to be an MSP plugin, here it is. Just copy and paste from below the line into a file, save it as "msp.xml" and put it into your plugins directory. You can also download it from:


http://www.mushclient.com/plugins/msp.xml






<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE muclient>
<!-- Saved on Friday, August 09, 2002, 1:00 PM -->
<!-- MuClient version 3.25 -->

<!-- Plugin "msp" generated by Plugin Wizard -->

<muclient>
<plugin
   name="msp"
   author="Nick Gammon"
   id="7da63d78d9f91bebb5285127"
   language="VBscript"
   purpose="Emulates MSP (MUD Sound Protocol)"
   save_state="y"
   date_written="2002-08-09 12:58:11"
   requires="3.24"
   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 c:\mushclient\msp, 
but you can change that by typing:

  set_msp_path new_path

eg.

  set_msp_path d:\muds\mushclient\msp

You may need to enable MSP manually, as this plugin does
not do telnet negotiation. eg. On Dawn Of Time MUDs, type:

msp on

]]>
</description>

</plugin>


<!--  Get our standard constants -->

<include name="constants.vbs"/>

<!--  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>
</aliases>

<!--  Variables  -->

<variables>
  <variable name="msp_path">c:\mushclient\msp\</variable>
</variables>

<!--  Script  -->


<script>
<![CDATA[
'
' 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 - directory in variable
 
 world.Sound (world.getvariable ("msp_path") & 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

sub On_set_MSP_path (strName, strLine, aryWildcards) 

dim sPath

  sPath =  aryWildcards (1)

'
'  ensure trailing backslash
'
  
  if right (sPath, 1) <> "\" then
     sPath = sPath & "\"
  end if

  world.setvariable "msp_path", sPath 
  world.note "MSP sound files will be obtained from " & _
             sPath 
end sub


]]>
</script>


<!--  Plugin help  -->

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

<script>
<![CDATA[
Sub OnHelp (sName, sLine, wildcards)
  World.Note World.GetPluginInfo (World.GetPluginID, 3)
End Sub
]]>
</script> 

</muclient>

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Fri 09 Aug 2002 03:30 AM (UTC)
Message
After re-reading your post a bit more carefully I realise I have not done exactly what you asked for, which is to download the sound files, however the plugin at least automates the scripting of the MSP script suggested in an earlier forum post. Thus, you only have to do two rather simple steps:

1. Install the plugin
2. Download and unzip the sound files

It could be worse. :)

I have deliberately put the path to the sound files into a variable, since the variable can be different per world, so you could have the same plugin in multiple worlds, each one using a different set of sound files.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Grizz   (3 posts)  [Biography] bio
Date Reply #4 on Fri 28 Sep 2007 09:05 AM (UTC)
Message
I get an error message when sounds attempt to play


Unable to play........ Reason:Cannot determine device type from the given file name extension
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Fri 28 Sep 2007 11:01 PM (UTC)
Message
What file name are you attempting to play?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Grizz   (3 posts)  [Biography] bio
Date Reply #6 on Sat 29 Sep 2007 11:49 PM (UTC)
Message
Any sound files I've downloaded from http://www.coremud.org/sounds/core10.zip

I unzipped the entire package into C:\Program Files\MUSHclient\MSP and used set_msp_path to that directory.

When viewing the msp file all of the sounds are listed as windows media player capable.

When mud sound is turned on without the pluggin active the text sent to the client is !!SOUND(transit)
[Go to top] top

Posted by Grizz   (3 posts)  [Biography] bio
Date Reply #7 on Mon 01 Oct 2007 12:54 PM (UTC)

Amended on Mon 01 Oct 2007 01:03 PM (UTC) by Grizz

Message
Ok I see the problem is that the mud does not send the .wav tag. Two problems

1 I tried the solution that was given for Cbond in http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=783
to no avail.

2 Also amidst the mud's .wav files are .mid files aswell.

I'm an utter newb to code there are about 57 different sound files. Would the best route be to make triggers and script(whatever that demon stuff is?) for each one manually setting the .wav and .mid ?
[Go to top] top

Posted by Shadowfyr   USA  (1,786 posts)  [Biography] bio
Date Reply #8 on Tue 02 Oct 2007 02:55 AM (UTC)

Amended on Tue 02 Oct 2007 03:02 AM (UTC) by Shadowfyr

Message
Hmm. Here is one suggestion:

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(".")  
Set fc = f.Files 
Set ff = f.SubFolders 
For Each f1 in ff	
  note f1.name
Next  
note " "
For Each f1 in fc
  note f1.name
Next  
Set ff = nothing
Set fso = nothing
Set f = nothing
Set fc = nothing

This code will, at least on my system, and I presume on any others with VBscript installed, read the directory given in "GetFolder", and return a list of files and directories.

This could be used in two ways, if added to the plugin. Method 1: Benefits - You only need to update the list of files once each time you run the plugin, by adding a call to it in the "onplugininstall" function, though, I make it a separate one here, so you can also call it from an alias, if you add new sounds, etc.


sub OnPluginInstall()
  call UpdateList("","","")
end sub

redim file_list()
sub UpdateList(a, b, c)
  Set fso = CreateObject("Scripting.FileSystemObject")
  Set f = fso.GetFolder(".")  
  Set fc = f.Files
  count = 0
  for all f1 in fc
    count = count + 1
  next
  redim file_list(count)
  count = 0
  for all f1 in fc
    'Yes, some twits are dumb enough to encode an .mpg with only audio, then wonder why
    'it won't play in things like winamp..., hence the support for looking for .mpg or .mpeg.
    'This is mostly just an example of how to handle extensions longer than three characters,
    'assuming the code even works right.
    dot = instr(".",f1.name)
    if instr(mid(f1.name,dot,len(f1.name)-dot, ".mid.wav.wma.mpg.mpeg") then
      file_list(count) = f1.name
      count = count + 1
    end if
  next
end sub


Then change the code for playback to do:

' play sound - directory in variable
 
 for x = 0 to ubound(file_list)
  if file_list(x) = sSound then
   world.Sound (world.getvariable ("msp_path") & sSound)
  else
    note "Sound not installed in directory " & world.getvariable ("msp_path") & "!"
  end if


The "other" method would be to instead do this:

' play sound - directory in variable

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(".")  
Set fc = f.Files
success = 0
for all f1 in fc
  if f1.name = sSound then
    world.Sound (world.getvariable ("msp_path") & sSound)
    success = 1
  end if
next
if success = 0 then
  note "Sound not installed in directory " & world.getvariable ("msp_path") & "!"
end if
Set ff = nothing
Set fso = nothing
Set fc = nothing


Obviously the second version is far shorter, and can handle new sounds, but it has to create the system object and read the directory "every single time" it wants to play something.

Still, its probably less complicated to add, especially since I don't provide the alias needed to call the "update" directly. The only real disadvantage, other than maybe some minor lag as the directory gets read each time, is that, since no copy of the list is kept, you can't add code to simply show all of the sound files you have installed. Note also, if you wanted to make things more robust, you would also want to make the ".mid.wav.wma" part, in the first example, so its stored in a variable/MXP element, so that it could be adjusted to include other end types.

Oh, the other reason to use the second version, even if the first has some advantages, is simply that I am 99.9% sure that the second version will work as written. The first method **should** work, but I haven't tested the code to make sure its bug free. ;) lol

Feel free to adjust one or the other to work better Nick. Since there are major advantages to version #1, especially if you could port it to Lua, where I presume the entire data structure for the file list could be loaded into a table.

---

Been a while since I wrote anything like this. Kind of fun to get back into it again. lol
[Go to top] top

Posted by Shadowfyr   USA  (1,786 posts)  [Biography] bio
Date Reply #9 on Wed 03 Oct 2007 01:01 AM (UTC)
Message
Snort... Silly me. Found and even simpler solution, if all you want to do, as in this case, is see if the file is there or not:

' play sound - directory in variable

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.fileExists(world.getvariable ("msp_path") & sSound)  
if f then
  world.Sound (world.getvariable ("msp_path") & sSound)
else
  note "Sound not installed in directory " & world.getvariable ("msp_path") & "!"
end if
Set f = nothing
Set fso = nothing


Didn't even think about looking to see if that function existed. There is a page on the functions for the file system stuff here:

http://www.tutorial-web.com/asp/fso/index.asp

----------------

Note, sounds are one thing in Mushclient we might want to take a look at internally. Currently when playing a sound Mushclient simply assumes that the default channel it uses will be free, without any way to check, so one sound overrides the other already playing. Properly behaving programs don't do that, but instead ask if a channel is available (somehow), then play it through the available channel. At some point it may be useful to not only fix this, but, even if not directly fixable, at least provide a way to tell it to play on a *different* channel, so you can loop music or mix sounds, instead of trying to shove all of them through the same pipe, as it where.
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #10 on Sun 10 Aug 2014 05:42 AM (UTC)
Message
An improved version of the plugin, written in Lua, is described here:

http://www.gammon.com.au/forum/?id=12542&reply=6#reply6

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


38,501 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]