MUSHclient version 4.84
I'm working on a plugin and I wanted to make it so that the sounds would work regardless of the MUSHclient folder's location. After searching the forums I decided to use the OnPluginPlaySound callback.
I renamed the sounds in the plugin to just the file names and everything worked great. Then I noticed that the sounds in my world triggers were making beeps instead of playing the correct sounds.
After some troubleshooting, I changed the OnPluginPlaySound to print some Notes.
I then used Simulate to continue testing sound triggers from outside the plugin and from inside the plugin. To my surprise, the triggers outside the plugin were also being processed by the OnPluginPlaySound function. MUSHclient was simply passing the enitre path of the sound file as 's'.
I read the help file for OnPluginPlaySound and I'm honestly not sure if this is intended behavior or not. However, my understanding was that plugins were intended to stand on their own. It doesn't make sense to me that OnPluginPlaySound grabs sounds from outside the plugin where it is called.
If this is intended behavior, maybe we could get a version OnThisPluginPlaySound or something that only grabs internal sounds?
I came up with the following workaround that has solved my problem for now.
I'm working on a plugin and I wanted to make it so that the sounds would work regardless of the MUSHclient folder's location. After searching the forums I decided to use the OnPluginPlaySound callback.
function OnPluginPlaySound (s)
Sound (GetInfo(57) .. "Sounds\" .. s)
end -- OnPluginPlaySound
I renamed the sounds in the plugin to just the file names and everything worked great. Then I noticed that the sounds in my world triggers were making beeps instead of playing the correct sounds.
After some troubleshooting, I changed the OnPluginPlaySound to print some Notes.
function OnPluginPlaySound (s)
Note (GetInfo(57))
Note (s)
Note (GetInfo(57) .. "Sounds\" .. s)
Sound (GetInfo(57) .. "Sounds\" .. s)
end -- OnPluginPlaySound
I then used Simulate to continue testing sound triggers from outside the plugin and from inside the plugin. To my surprise, the triggers outside the plugin were also being processed by the OnPluginPlaySound function. MUSHclient was simply passing the enitre path of the sound file as 's'.
C:\Program Files (x86)\MUSHclient\worlds\ -- GetInfo(57)
C:\Program Files (x86)\MUSHclient\worlds\Sounds\Mine.wav -- s
C:\Program Files (x86)\MUSHclient\worlds\Sounds\C:\Program Files (x86)\MUSHclient\worlds\Sounds\Mine.wav -- GetInfo(57) .. "Sounds\" .. s
I read the help file for OnPluginPlaySound and I'm honestly not sure if this is intended behavior or not. However, my understanding was that plugins were intended to stand on their own. It doesn't make sense to me that OnPluginPlaySound grabs sounds from outside the plugin where it is called.
If this is intended behavior, maybe we could get a version OnThisPluginPlaySound or something that only grabs internal sounds?
I came up with the following workaround that has solved my problem for now.
function OnPluginPlaySound (s)
b, e = string.find (s, "^%a:\") -- check if s begins with drive letter
if b and e then -- if both are true, then s began with a drive letter
Sound (s) -- so play s without prepending anything to it
else
Sound (GetInfo(57) .. "Sounds\" .. s)
end -- if
end -- OnPluginPlaySound