Register forum user name Search FAQ

Gammon Forum

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 ➜ Bug reports ➜ XML Includes are dependant on current working directory

XML Includes are dependant on current working directory

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


Posted by Worstje   Netherlands  (899 posts)  Bio
Date Thu 27 Jul 2006 09:35 PM (UTC)
Message
I have a plugin that uses <include> to include other files with scripting in them.

The problem is that when a recent action sets the path AWAY from the path your plugin is, (re)loading it will give errors since it cannot find the files. The plugin will, however, appear in Plugins as if it had been loaded.

Example situations in which this happens:
* Opening a worldfile that is in another directory than said plugin. I get spammed with errors (I include like 20 files across a few plugins).
* Opening another plugin in another directory through Plugins>Add, and trying to reload said plugin.

Temporary fix:
1) Try to go to Plugins>Add, and load the file again. It will error, saying something with that id was already loaded.
2) Click Reinstall. It will work now, because apparently the path has been changed.
Top

Posted by Nick Gammon   Australia  (23,140 posts)  Bio   Forum Administrator
Date Reply #1 on Thu 27 Jul 2006 10:29 PM (UTC)
Message
See this recent post:

http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=7220

I can see this is a bit of an ongoing problem, reluctant as I am to fiddle with the "current directory" it might be necessary.

The scenario you describe, by invoking the standard file dialog box, changes the current directory back to where you want it.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Worstje   Netherlands  (899 posts)  Bio
Date Reply #2 on Thu 27 Jul 2006 11:24 PM (UTC)
Message
I hadn't seen that post although I did search, I'm sorry. But it wouldn't be an option for me for two reasons:

1) I use Python, not Lua.
2) I recall to have read that ImportXML imports into the global namespace, which would effectively break my plugin (unless I'd add a lot of checks on the plugin-id, which would nullify the use of <include> in the first place).

The problem is at load time, right? I am not sure where this code is interpreted (mush or some other library), but maybe relative paths starting with ./ can, by default, be substituted with the path the plugin is in?

Examples. World file is C:\Program Files\MUSHClient\worlds\Test.mcl. Plugin that calls it would be D:\Curing\Main.xml:

<include name="$MUSHCLIENT$\worlds\plugins\Python.pys" /> -- would load C:\Program Files\MUSHClient\worlds\plugins\Python.pys (so default modules and files can be loaded)
<include name="Herbs.xml" /> -- would load C:\Program Files\MUSHClient\worlds\Herbs.xml (so current behaviour with working directory wouldn't break)
<include name="./Vials.xml" /> -- would load D:\Curing\Vials.xml
<include name="C:\Salves.xml" /> -- would load C:\Salves.xml

Would that be possible?
Top

Posted by Nick Gammon   Australia  (23,140 posts)  Bio   Forum Administrator
Date Reply #3 on Fri 28 Jul 2006 01:20 AM (UTC)
Message
ImportXML imports into the namespace of whatever plugin it is called from (or the main namespace). I tested that when doing my earlier suggestion.

However I take your point about the problem with it not being Lua.

However any language that is able to open a file could then read it in and call ImportXML.

I will look at temporarily changing the working directory during loading a plugin.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Worstje   Netherlands  (899 posts)  Bio
Date Reply #4 on Fri 28 Jul 2006 02:06 AM (UTC)
Message
Great. :D

The thing about ImportXML must have been an older bug that has been squashed since. I come here more often, hehe. :D

Is there a reason why my suggestion isn't possible though? I think manually parsing would be preferable over playing with the current directory to fit moods and grudges with the (re)loading of plugins.
Top

Posted by Nick Gammon   Australia  (23,140 posts)  Bio   Forum Administrator
Date Reply #5 on Fri 28 Jul 2006 04:34 AM (UTC)
Message
Sure, good idea.

In version 3.76 you will be able to use the following special strings inside the include directive:


  • $PLUGINSDEFAULTDIR - default directory for plugins
  • $PROGRAMDIR - directory MUSHclient executable is in
  • $WORLDDIR - directory current world is in
  • $PLUGINDIR - directory current plugin is in


You should be able to use these to make plugins load relative to themselves, eg.


<include name="$PLUGINDIR\myincludes.xml" />

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Indoum   Sweden  (17 posts)  Bio
Date Reply #6 on Fri 28 Jul 2006 03:39 PM (UTC)
Message
Awesome, I'm so looking forward to this version. Any ETA yet?
Top

Posted by Tsunami   USA  (204 posts)  Bio
Date Reply #7 on Fri 28 Jul 2006 07:12 PM (UTC)
Message
Ah, made my other post before I saw this ;) Thanks!
Top

Posted by Nick Gammon   Australia  (23,140 posts)  Bio   Forum Administrator
Date Reply #8 on Sat 29 Jul 2006 04:53 AM (UTC)
Message
Version 3.76 is now released.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,140 posts)  Bio   Forum Administrator
Date Reply #9 on Tue 05 Sep 2006 10:03 PM (UTC)
Message
This seems to be a bit of an ongoing problem, so version 3.80 adds a function ChangeDir - this lets you change the working directory to a known value.

Thus, before loading a plugin's extra files (eg. with the Lua "require" statement) you could change the working directory to that which contains the plugin first.

- 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.


31,778 views.

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

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.