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


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  ensuring working directory

ensuring working directory

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


Posted by Tspivey   Canada  (54 posts)  [Biography] 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?
[Go to top] top

Posted by Cino   Australia  (17 posts)  [Biography] 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?
[Go to top] top

Posted by Tspivey   Canada  (54 posts)  [Biography] 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.
[Go to top] top

Posted by Cino   Australia  (17 posts)  [Biography] 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.
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] 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
[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.


15,799 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]