[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]  General
. . -> [Subject]  MUSHClient giving error when loading plugin on startup
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

MUSHClient giving error when loading plugin on startup

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


Posted by Hadoryu   (3 posts)  [Biography] bio
Date Tue 22 Sep 2009 07:48 AM (UTC)
Message
Hello,

I've been using MUSHClient for a few years now and doing some scripting on it. I started recently on a Plugin that should be easily distributable/installable, but I've run into a small problem that I'm not sure how to address.

The plugin, when loaded, works fine. However, when you shut MUSH down and then start it up again and open the world that the plugin was installed in, it fails to load, giving two error messages:

Line 1012: Error processing include file "C:\Program Files\MUSHclient\worlds\plugins\Hadoryu Plugins\STP\StarterPack.xml" (include file not loaded)

^ this is from the .MCL

Line 1249: Error parsing script (problem in this file)

^ this is from the .XML of the plugin.

All I can see under Line 1249 is the opening of a script block. I've tried to figure out if there isn't an error there, but the plugin has no problems if I just load it up manually.

This is the plugin itself:

http://hadoryu.uuuq.com/starter_pack/STP.zip

It's looking to me like a bug, but I'm not sure.

Any ideas?
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Tue 22 Sep 2009 09:43 AM (UTC)
Message
Template:version Please help us by advising the version of MUSHclient you are using. Use the Help menu -> About MUSHclient.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Hadoryu   (3 posts)  [Biography] bio
Date Reply #2 on Tue 22 Sep 2009 10:37 AM (UTC)
Message
Sorry, I forgot to mention it. The problem initially came up with version 4.40. I then upgraded to 4.43 to test if that would fix it, but the result was the same.
[Go to top] top

Posted by Worstje   Netherlands  (899 posts)  [Biography] bio
Date Reply #3 on Tue 22 Sep 2009 03:18 PM (UTC)

Amended on Tue 22 Sep 2009 03:23 PM (UTC) by Worstje

Message
I am trying to reproduce your problem with the steps you described. To make sure I did so correctly, here's what I did and do on my way to fixing stuff.

1) Create a new world.
2) Save it as C:\Projects\Test.mcl
3) Extract your plugin to C:\Projects\tmp\
4) Load the plugin.
5) Save & close MUSHclient.
6) Restart MUSHclient. Load Test.mcl.
7) Errors I encountered were different from yours:

Scripting error popup:
[string "Plugin"]:638: attempt to call local 'f' (a nil value)
stack traceback:
	[string "Plugin"]:638: in function 'loadAfflictionColors'
	[string "Plugin"]:798: in main chunk

Starterpack.xml Notepad window:
Line 1249: Error parsing script (problem in this file)

Test.mcl:
Line  422: Error processing include file "C:\Projects\tmp\StarterPack.xml" (include file not loaded)


8) I found the following code: (do NOT forget that any <include> directives bump the line numbers - in this case, you are being confused with the line numbers by your constants.lua include!)
function loadAfflictionColors()
	SysNote("Loading Affliction colors from : "..AFFLICTION_COLORS_FILE)
	local f = loadfile(AFFLICTION_COLORS_FILE)
	f()
	return true
end


The error here is that you use loadfile(), yet do not check if it succeeded. I suggest you adjust it as follows to make debugging more easier:

function loadAfflictionColors()
	SysNote("Loading Affliction colors from : "..AFFLICTION_COLORS_FILE)
	local f = loadfile(AFFLICTION_COLORS_FILE)
	if (f ~= nil) then
		f()
		return true
	else
		Note("Could not load "..AFFLICTION_COLORS_FILE)
		return false
	end
end


9) Why could it not load the file? Simple, because it couldn't FIND the file. Looking at the definitions, we find:
AFFLICTION_TRIGGERS_FILE = "STP_triggers.lua"
AFFLICTION_CURE_TRIGGERS_FILE = "STP_cures.lua"
AFFLICTION_DIAGNOSIS_TRIGGERS_FILE = "STP_diagnosis.lua"
AFFLICTION_COLORS_FILE = "STP_affliction_colors.lua"
CURE_COLORS_FILE = "STP_cure_colors.lua"
EAT_AFFLICTION_PRIORITIES_FILE = "STP_eat_affliction_priorities.lua"
APPLY_AFFLICTION_PRIORITIES_FILE = "STP_apply_affliction_priorities.lua"
DRUG_AFFLICTION_PRIORITIES_FILE = "STP_drug_affliction_priorities.lua"
AUTOSIPPER_FILE = "STP_autosipper.lua"

at the top of your file. Suggested fix is as follows:
PLUGIN_PATH = GetPluginInfo(GetPluginID(), 20)

AFFLICTION_TRIGGERS_FILE = PLUGIN_PATH.."STP_triggers.lua"
AFFLICTION_CURE_TRIGGERS_FILE = PLUGIN_PATH.."STP_cures.lua"
AFFLICTION_DIAGNOSIS_TRIGGERS_FILE = PLUGIN_PATH.."STP_diagnosis.lua"
AFFLICTION_COLORS_FILE = PLUGIN_PATH.."STP_affliction_colors.lua"
CURE_COLORS_FILE = PLUGIN_PATH.."STP_cure_colors.lua"
EAT_AFFLICTION_PRIORITIES_FILE = PLUGIN_PATH.."STP_eat_affliction_priorities.lua"
APPLY_AFFLICTION_PRIORITIES_FILE = PLUGIN_PATH.."STP_apply_affliction_priorities.lua"
DRUG_AFFLICTION_PRIORITIES_FILE = PLUGIN_PATH.."STP_drug_affliction_priorities.lua"
AUTOSIPPER_FILE = PLUGIN_PATH.."STP_autosipper.lua"


10) Save the changes. Repeat steps 5) and 6).
11) No more errors.

Edit: Right, forgot the conclusion/summary thing.

The problem here, as always with MUSHclient plugins that won't load after restarting, is that they tend to depend on the current working directory. Depending on the users last open or save action, that can differ. In your case, your MCL was in another directory, and since it was most recently browsed in by the user, that is where the current directory pointed at - not the directory of your plugin.

The lesson here is to always make sure you feed MUSHclient absolute pathnames, even if you have to take a little bit more trouble in finding out what that path would be.
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #4 on Wed 23 Sep 2009 01:21 AM (UTC)

Amended on Wed 23 Sep 2009 01:22 AM (UTC) by Nick Gammon

Message
Very detailed explanation, Worstje. :-)


Worstje said:

The error here is that you use loadfile(), yet do not check if it succeeded.


The function 'dofile' is designed to do exactly that. It loads the file, checks for errors, and then executes the loaded function:

http://www.gammon.com.au/scripts/doc.php?lua=dofile

I agree with your other comments. Anything that relies upon the "current directory" is likely to fail from time to time, unless you can absolutely be sure what the current directory is.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Hadoryu   (3 posts)  [Biography] bio
Date Reply #5 on Fri 25 Sep 2009 07:47 AM (UTC)
Message
That worked, thank you!

Sorry for the late reply. And yes, the error message ended up confusing me more than helping, I think. Will keep it in mind in the future.
[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.


4,685 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]