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


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  MXP and Pueblo
. . -> [Subject]  MXP Sound problems.

MXP Sound problems.

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


Pages: 1 2  

Posted by Johnathan Allen   (49 posts)  [Biography] bio
Date Mon 08 Sep 2003 09:36 AM (UTC)
Message
Hello, I'm trying to get sounds to work with my client, I have the plugin installed, and the sounds installed, and the plugin pointing to the proper location, but I don't think that Mushclient is reading the tag properly. In the MXP debug window, I get:


A 20000: (  239) MXP element: <sound FName="mm_door_open.*" V=100 L=1 P=50 T="misc">
W  5012: (  239) MXP tag <sound> is not implemented
W  5015: (  239) Unused argument for <sound>: fname="mm_door_open.*"
W  5015: (  239) Unused argument for <sound>: v="100"
W  5015: (  239) Unused argument for <sound>: l="1"
W  5015: (  239) Unused argument for <sound>: p="50"
W  5015: (  239) Unused argument for <sound>: t="misc"


I'm not sure whats wrong, can you help me out?
[Go to top] top

Posted by Johnathan Allen   (49 posts)  [Biography] bio
Date Reply #1 on Mon 08 Sep 2003 10:21 AM (UTC)
Message
Is there a way to manually define mxp elements on the client side?
[Go to top] top

Posted by Nick Gammon   Australia  (22,982 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Wed 10 Sep 2003 10:24 PM (UTC)
Message
Yes, you can do this. You need to add a script routine to your world script file, here is an example:


function OnMXPStartTag (name, args, mylist)

  dim i
  dim fn
  dim arg

'
'  only proces sound tags
'

  if name <> "sound" then 
    exit function
  end if

'
'  find the sound file name
'

  if not IsEmpty (mylist) then
    for i = lbound (mylist) to ubound (mylist)
      arg = split (mylist (i), "=")
      if arg (0) = "fname" then
        fn = arg (1)
      end if
    next
  End If

'
'  play sound
'

  if fn <> "" then
    fn = Replace (fn, "*", "wav")
    Sound "c:\mysounds" & fn
  end if

  ' suppress sound tags (handle them ourselves)	

  OnMXPStartTag = 1

end function



What you will then need to do is add "OnMXPStartTag" as the "Opening Tag" script file in the scripting configuration page (click the "MXP" button).

What is happening here is that when MUSHclient gets the MXP start tag "sound" it calls the script. The script gets passed all the sound arguments (FName="mm_door_open.*" V=100 L=1 P=50 T="misc") in an array.

It walks the array looking for the "FName" argument and then saves the filename.

Then it uses the "Sound" script command to play that sound.

In your example it cannot play the sound "mm_door_open.*" so I have replaced the "*" with "wav".

You may also need change the directory where it is looking for the sounds. I used "c:\mysounds".

Finally this line stops the line from being processed by MUSHclient and thus giving an error message:


OnMXPStartTag = 1

- Nick Gammon

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

Posted by Johnathan Allen   (49 posts)  [Biography] bio
Date Reply #3 on Thu 11 Sep 2003 11:38 AM (UTC)
Message
Thanks Nick. :)
[Go to top] top

Posted by Johnathan Allen   (49 posts)  [Biography] bio
Date Reply #4 on Mon 15 Sep 2003 12:09 AM (UTC)

Amended on Mon 15 Sep 2003 12:28 AM (UTC) by Johnathan Allen

Message
Umm. I'm trying to wrap this all into a plugin, but the OnMXPStartTag isn't calling the plugin, it only works if I insert the code into my main script. Can you address the tag to a plugin?
[Go to top] top

Posted by Johnathan Allen   (49 posts)  [Biography] bio
Date Reply #5 on Mon 15 Sep 2003 01:29 PM (UTC)
Message
Okay, let me elaborate on what I'm doing...

This is my plugin.

Quote:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE muclient>
<!-- Saved on Friday, September 12, 2003, 12:23 AM -->
<!-- MuClient version 3.24 -->

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

<muclient>
<plugin
name="MM_MSP_Emulation"
author="Nick Gammon with alterations by ****** for use with MateriaMagica IEN"
id="74c06c730af9e17ac98dc126"
language="VBscript"
purpose="Emulates MSP (MUD Sound Protocol) on MateriaMagica"
save_state="y"
date_written="2003-09-11 12:12:11"
requires="3.24"
version="1.0"
>
<description trim="y">
<![CDATA[
Type: "msp:help" to see this help.

See:

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:\Program Files\MUSHclient\msp,
but you can change that by typing:

set_msp_path new_path

eg.

set_msp_path C:\Program Files\MUSHclient\msp

This does require sound to be enabled, so type:

set sound on

Also, this requires you to manually set a few things.

Set MXP/Pueblo on, follow these steps:

1.) Press Ctrl+Alt+U, or use Game -> Configure -> MXP / Pueblo
2.) Set "Use MXP/Pueblo to "On Command"
3.) Uncheck all other options.

Now we need to add something to the scripting interface.
1.) Press Shift+Ctrl+6 or use Game -> Configure -> Scripting
2.) Press the MXP button
3.) In the Opening Tag box, insert "OnMXPStartTag", without the quotes.

And finally, you need to specify either .wav files, or .mp3 files,
type:

set_msp_type (file type)

eg.

set_msp_type wav
or
set_msp_type mp3

Any questions, feel free to contact ******* in game.

]]>
</description>

</plugin>


<!-- Get our standard constants -->

<include name="constants.vbs"/>

<!-- Aliases -->

<aliases>
<alias
script="On_set_MSP_path"
match="set_msp_path *"
enabled="y"
>
</alias>
<alias
script="On_set_MSP_type"
match="set_msp_type *"
enabled="y"
>
</alias>
</aliases>

<!-- Variables -->

<variables>
<variable name="msp_path">C:\Program Files\MUSHclient\msp</variable>
</variables>

<!-- Script -->


<script>
<![CDATA[
'
' Script to emulate MSP on MateriaMagica.
'

Sub On_set_MSP_type (strName, strLine, arrWildCards)

dim sType

sType = arrWildCards (1)

'
' ensure either "wav" or "mp3" was specified
'


Select Case sType
Case "wav"
world.setvariable "msp_type", sType
world.note "MSP will now use the .wav extension"
Case "mp3"
world.setvariable "msp_type", sType
world.note "MSP will now use the .mp3 extension"
Case Else
World.Note "You must specify either 'wav' or 'mp3' for sound file extension."
End Select

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



Function OnMXPStartTag (name, args, mylist)

dim i
dim fn
dim arg

'
' only process sound tags
'

if name <> "sound" then
exit function
end if

'
' find the sound file name
'

if not IsEmpty (mylist) then
for i = lbound (mylist) to ubound (mylist)
arg = split (mylist (i), "=")
if arg (0) = "fname" then
fn = arg (1)
end if
next
End If

'
' play sound
'

if fn <> "" then
fn = Replace (fn, "*", world.getvariable ("msp_type"))
world.Sound msp_Path & fn
end if

' suppress sound tags (handle them ourselves)

OnMXPStartTag = 1

end function


]]>
</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>


I'm trying to make a portable plugin for sounds with my mud. The only things that are hanging me up are the (on_mxp_open_tag="OnMXPStartTag" ), since I can't think of a way to automate that refrence to be installed into the world file (found under " <world " in the .mcl file, and the plugin doesn't work because theres no connection between "OnMXPStartTag" and the plugin. The script itself works fine if I add all the aliases and stuff to the regular world alias/trigger/script, but not as an independent standalone plugin.

I thought about adding a OnMXPStartTag sub and refrencing it to the plugin, but that kind of negates the portablility and automatic installation. Again, I'm shooting for ease of use and portablility, since this is going to be availible for download from the mud's web page. Is there an easy way to point OnMXPStartTag to the plugin?

[Go to top] top

Posted by Shadowfyr   USA  (1,786 posts)  [Biography] bio
Date Reply #6 on Sat 20 Sep 2003 12:29 AM (UTC)
Message
The problem here is basically the same as why there is a CallPlugin command, instead of a way to directly call a sub in a plugin script. I think it is a serious flaw and has made numerous plugin desigs impossible. I am not sure of the precise reason for it, but it mostly comes down to mushclient not knowing before hand what subs to expect in a script. Since the main script executes in a global namespace, the client can make direct calls too it, but plugins each exist in a seperate thread of something, in order to prevent conflicts with variables and things of that sort. MXP subs can't call using a plugin ID, so they have no way to know 'where' to look for the block of code that needs to be executed, even if they do have a name to look for.

There has got to be a better way imho. Being able to tell the world file the ID of a plugin to execute MXP stuff would help, with a blank ID defaulting to the main world, but calling plugins is still a pain. It would have been much better imho to do this:

set Handle = GetPluginHandle(BSTR Plugin ID)
Handle.SomeSubName(Arguement1, Arguement2, ...)

The method used now is inconvenient and requires complicated code to be added into one special sub, where everything has to be broken up and passed on to what you intended to call in the first place. This is not only unecessarily complicated, but confusing from the stand point of trying to call anything in a plugin. Especially since it doesn't even reflect the standard way that all other objects, commands and code is used for anything else in a script.

In theory.. If you get a world handle, so that you are executing global calls with it, instead of plugin calls, you might be able to set the names used for the scripts, then use ImportXML to 'import' the blocks of code containing those into the main world. They could either perform the actual commands or use CallPlugin to pass the needed information to your plugin and have that do the job. This is 'theory' though, I don't know if creating a handle to mushclient in the script will actually give you direct control over the main world, or if you would just be giving your script a roundabout way to talk to itself. lol

Hmm. Thinking on it, I am not sure it is even possible. Maybe if you used python and a Mushclient 'wrapper' to give the script information on the internals, but you would need to do something like this in VBScript:

a = getworldid(worldname)
dim b as object 'Create a generic object type.
'???? b = a ???? I have no idea what is needed here to have it work...,
'but you have to make the generic object 'become' your world some how.
b.inportXML("Your code here")

In Python, *with the wrapper*, it would be much easier, but it is still rediculous to have to do this sort of thing imho. Someone that understood COM better and had a lot more patience than me could probably make it work, but not me.

There is another alternative though. It would be reading the world file itself in to your script, checking to see if the code is there already and if not, then writing the entire file back in, including the code you needed to add. This is dangerous, nearly as complicated and still quite insane to have to do. :p
[Go to top] top

Posted by Johnathan Allen   (49 posts)  [Biography] bio
Date Reply #7 on Sat 20 Sep 2003 12:59 AM (UTC)
Message
It'd be nice if we can do custom distributions. I've sort of solved it by making a .mcl file and a vb script file for download. But a whole custom distribution would be pretty nice. It'd allow me to make all the appropriate settings availible for users.
[Go to top] top

Posted by Shadowfyr   USA  (1,786 posts)  [Biography] bio
Date Reply #8 on Sat 20 Sep 2003 04:01 AM (UTC)
Message
Well, hopefully Nick will find a way to use the plugins like objects, instead of the currect insane way. That would help some.

The second things is some means to import XML permanently into the world file and save it, or even a direct way to respond to MXP stuff in plugins, either one of which would solve your problem. It gets frustrating when such basic things require either a very unfriendly non-distributable solution or wrapping your mind around some convaluted and insane solution like the one I suggested, which would probably never work anyway....

Feels like traversing a bloody mazer without a flashlight sometimes. lol

So Nick.. Why is it exactly that plugins can't use the Object.Command method for calling plugins, aside from you not implimenting such? It seems to me to be far more consistent, considering what we try and would like to do with them. Even scripts calling other 'external' scripts would use this method, but not being able to use it 'in' a script running within Mushclient. :p
[Go to top] top

Posted by Shadowfyr   USA  (1,786 posts)  [Biography] bio
Date Reply #9 on Sat 20 Sep 2003 04:10 AM (UTC)
Message
Hmm.. Here is an idea though Johnathan. Under the file menu is an option for 'Import'. You may be able to create an mcl file that only has the options you specifically need and possibly some script code (or an 'include' directive that imports the needed scripts). It isn't elegant, but if the importer doesn't complain about things that are missing from the file (i.e. you left out to prevent it from overriding the settings), it 'may' work. It isn't A) safe or B) the best solution, but it may actually work.
[Go to top] top

Posted by Johnathan Allen   (49 posts)  [Biography] bio
Date Reply #10 on Sat 20 Sep 2003 04:45 AM (UTC)
Message
Nothing there for code... :(
[Go to top] top

Posted by Nick Gammon   Australia  (22,982 posts)  [Biography] bio   Forum Administrator
Date Reply #11 on Sat 20 Sep 2003 08:17 AM (UTC)
Message
I can probably make without too much trouble it be possible to have MXP callbacks work in plugins. That would solve your problem I think.

- Nick Gammon

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

Posted by Johnathan Allen   (49 posts)  [Biography] bio
Date Reply #12 on Sun 21 Sep 2003 03:49 PM (UTC)
Message
That would be awesome Nick. :)
[Go to top] top

Posted by Nick Gammon   Australia  (22,982 posts)  [Biography] bio   Forum Administrator
Date Reply #13 on Sun 21 Sep 2003 11:00 PM (UTC)
Message
Well, I didn't know that. :) It seems I already have done it. The following pre-coded names are available as plugin callbacks:


OnPluginMXPstart
OnPluginMXPstop
OnPluginMXPopenTag
OnPluginMXPcloseTag
OnPluginMXPsetVariable
OnPluginMXPerror




OnPluginMXPopenTag

It seems that in the case of OnPluginMXPopenTag it the callback expects a single argument in the form:

name,arguments

In other words, you would get something like this:

sound,FName="mm_door_open.*" V=100 L=1 P=50 T="misc"

Thus you could use Split to break up the line into "sound" and the arguments, and then proceed much the same as before.


OnPluginMXPcloseTag

Just to complete the documentation, in the case of OnPluginMXPcloseTag you get the tag name followed by the text of the tag. eg.

<b>Hi there</b>

In this case the close tag for "b" would have as its argument:

b,Hi there


OnPluginMXPsetVariable

For OnPluginMXPsetVariable the argument is variable name=value, eg.

RoomName=Red Square


OnPluginMXPerror

For OnPluginMXPerror the argument is:

level,number,line_number,message

eg.

I,10008,417,MXP mode change from 'open' to 'permanently secure'





- Nick Gammon

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

Posted by Johnathan Allen   (49 posts)  [Biography] bio
Date Reply #14 on Mon 22 Sep 2003 05:22 AM (UTC)
Message
Can you think of a way to insert the OnPluginMXPopenTag call with the OnPluginInstall function?
[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.


59,667 views.

This is page 1, subject is 2 pages long: 1 2  [Next page]

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]