Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ General
➜ ensuring working directory
ensuring working directory
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Tspivey
Canada (54 posts) Bio
|
Date
| Sat 01 Jul 2006 08:12 PM (UTC) |
Message
| How can I ensure that mushclient always gets its sounds from one directory, i. e. worlds\gw2 from the mushclient main directory? I want to send my world file to someone else, and even for my own use, I want to use something like:
Sound("swings/8.wav")
but without specifying a path name. Running os.execute("cmd") shows that my working directory goes from documents and settings upon world open, to the mushclient plugins directory, etc. Any way to keep it in the mushclient.exe program directory?
| Top |
|
Posted by
| Cino
Australia (17 posts) Bio
|
Date
| Reply #1 on Sun 02 Jul 2006 12:55 PM (UTC) |
Message
| You can use GetInfo [ http://www.gammon.com.au/scripts/function.php?name=GetInfo ] to return various directories.
For a folder of sound files in the world directory, the path (in Lua) would be, GetInfo(57).."soundfolder\soundfile.wav"
, that is probably about as generic as it can get? If you put that in a Note, something like c:\mushclient\worlds\soundfolder\soundfile.wav would be printed.
I see that the shortcut for MUSHclient that the installer put in the start menu has its "Start in" box set to "C:\Documents and Settings\myusername\Start Menu\Programs\MUSHclient" . This should be easy enough to change to your mushclient directory, or maybe you can leave it empty? I don't really understand what it is for, as other shortcuts sometimes have nothing and each works fine :). Anyway, with using the GetInfo, the actual working directory shouldn't matter? | Top |
|
Posted by
| Tspivey
Canada (54 posts) Bio
|
Date
| Reply #2 on Sun 02 Jul 2006 03:35 PM (UTC) |
Message
| That would work fine, except in the browse for sound dialog. I want to send my world file to someone else, but have everything off the mushclient directory, no matter what it's called. I can't write GetInfo(57) in the sound browse dialog, and having everything send to script is rather annoying to set up. I'm thinking that Mushclient should put itself in the directory containing the .exe, and stay there. | Top |
|
Posted by
| Cino
Australia (17 posts) Bio
|
Date
| Reply #3 on Mon 03 Jul 2006 03:21 AM (UTC) Amended on Mon 03 Jul 2006 03:23 AM (UTC) by Cino
|
Message
| In your OnWorldOpen, could put this to modify any sound attributes.
for k,v in pairs(GetTriggerList()) do
sound_dir = sound_dir or "sounds"
-- check if directory is in the right place and if the trigger has a sound file
if not string.find(GetTriggerOption(v,"sound"),GetInfo(57)) and not GetTriggerOption(v,"sound")=="" then
-- patch up the sound attribute of trigger with incorrect path
SetTriggerOption(v,"sound",string.gsub(GetTriggerOption(v,"sound"),"^.+\\"..sound_dir.."\\(.+)",GetInfo(57)..sound_dir.."\\%1",1)
end
end
Modify the actual directories as you like :). The sound file paths are stored as absolute paths, so I see little option other than to use scripting.
You would still be able to pick sounds as normal, and the first time someone else runs your files, the paths should be changed automatically. | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #4 on Mon 03 Jul 2006 06:47 AM (UTC) |
Message
| See:
http://www.gammon.com.au/scripts/doc.php?general=plugin_callbacks
Just make a plugin callback OnPluginPlaySound. In that you can prepend a pathname (or check if one is there) and then call Sound to play the resulting path.
eg.
function OnPluginPlaySound (s)
Sound ("some_directory\\" .. s)
end -- OnPluginPlaySound
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | 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.
17,951 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top