Installing plugins using windows environment variables.

Posted by Bobble on Fri 23 Jul 2010 04:30 AM — 10 posts, 32,610 views.

Canada #0
Hello all!

I currently use MUSH on two different computers. In order to save time transferring the world files, I've used Dropbox to store my world files and plugins.

This has caused a bit of a problem however since the folder these files are stored on on each computer is slightly different. So when I load up a world file, it looks for the plugins in the wrong folder.

What I've done is created the same environment variable that leads to the proper folder where the plugins are stored on each computer.

What I wanted to know is if there's any way of modifying the world file or anything else so that it loads the plugins using the environment variable to guide it to the proper folder.

Any help would be appreciated and I'd be happy to provide any clarification as needed.

Take care.
Australia Forum Administrator #1
Well, skipping the environment variable for the moment (although you can probably incorporate it), if you get the sqlite3 command-line program from the sqlite site, you could make a batch file that updates the plugins directory location like this:

sqlite3 mushclient_prefs.sqlite "UPDATE prefs SET value = 'C:\Program Files\MUSHclient\my_plugins\' WHERE name = 'PluginsDirectory'"


For versions 4.54 onwards you may also want to set up the plugins state file directory:



sqlite3 mushclient_prefs.sqlite "UPDATE prefs SET value = 'C:\Program Files\MUSHclient\my_plugins\state\' WHERE name = 'StateFilesDirectory'"



Make sure you have the trailing slash on the directory name.

This assumes you have sqlite3.exe somewhere in your path. You would amend the path names as required. Maybe put the environment variable there instead of the hard-coded path name.

You would need to run this in the directory which has the copy of mushclient_prefs.sqlite in it that MUSHclient uses to start up.

Australia Forum Administrator #2
You would also want to make sure that the plugins listed in the world file (the .MCL file) does not have full pathnames. That way, it will take the pathname for the plugins directory from the prefs table, and add on the name of the actual plugin.
Canada #3
Hi Nick,

I've got the batch file set up and when I run it it changes the preferences perfectly. The only thing I'm not sure how to do is get the batch file to run each time I start MUSHclient.

Could you or anyone else give me some direction on this?
Australia Forum Administrator #4
In the batch file, after you have updated the database, put the line:


mushclient.exe


That will run MUSHclient. So then just run the batch file instead of MUSHclient (you can make a shortcut to it even, and put that on the Desktop).
Canada #5
Hey Nick,

Thanks for that. I should have come back and let you know that I'd figured that one out on my own. Just had a braincramp before posting.

However, I've run into one final (I hope) problem. While the plugins are all working, the path to the script file and the script editor are staying the same. Is there a way to change the path to the editor and script file via a batch file or some other means?
Australia Forum Administrator #6
A script like this would do it:


SetAlphaOption ("script_editor", os.getenv ("MUSHCLIENT_EDITOR"))
SetAlphaOption ("script_filename", os.getenv ("MUSHCLIENT_SCRIPT_FILE"))


However the problem is, when to execute it? You have a bit of a chicken-and-egg situation here. Early on in the loading process, it loads the script engine, so putting those lines into the script file is too late.

What I think will work is putting that into the "Lua Sandbox" (a global configuration). This is executed before loading the script file, so it might just slip in, in time to change the script filename in world startup.
Canada #7
I'm a bit unclear where to put the path in those two lines. Something like this?

SetAlphaOption ("script_filename", os.getenv ("%MUSHCLIENT%\scripts\basic_system.lua"))

Amended on Sun 25 Jul 2010 04:16 AM by Bobble
Australia Forum Administrator #8
I just set up (in the Windows Control Panel) and environment variable called MUSHCLIENT_EDITOR which pointed to the editor location. Then os.getenv just pulls in whatever that has in it.
Canada #9
Works like a charm on both computers. Thanks a bunch Nick!