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

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Bug reports
. . -> [Subject]  XML Includes are dependant on current working directory
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

XML Includes are dependant on current working directory

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


Posted by Worstje   Netherlands  (899 posts)  [Biography] 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.
[Go to top] top

Posted by Nick Gammon   Australia  (21,609 posts)  [Biography] 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
[Go to top] top

Posted by Worstje   Netherlands  (899 posts)  [Biography] 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?
[Go to top] top

Posted by Nick Gammon   Australia  (21,609 posts)  [Biography] 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
[Go to top] top

Posted by Worstje   Netherlands  (899 posts)  [Biography] 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.
[Go to top] top

Posted by Nick Gammon   Australia  (21,609 posts)  [Biography] 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
[Go to top] top

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

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

Posted by Nick Gammon   Australia  (21,609 posts)  [Biography] 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
[Go to top] top

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


8,530 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 FutureQuest]