<include> and linenumbers

Posted by Worstje on Tue 08 May 2007 07:53 PM — 4 posts, 11,757 views.

Netherlands #0
I use <include> to organize my plugins source over various files, depending on the precise part of the global purpose of the plugin. But if I make a typo somewhere, there's a chance I'll be seeing this:

Script error
Plugin: Curing (called from world: Blahblahblah)
Execution of line 7122 column 7
Function/Sub: LoadCuring called by alias
Reason: processing alias ""
invalid syntax

I believe that MUSHclient appends all the <script> blocks and then runs the interpreter, which gives the linenumber. Could there be an option that either:

1) displays the actual <include> filename and the line-number in that file?
2) displays the line in question.

Also, logically line numbers have historically been off a bit due to the fact <trigger(s)>, <alias(es)>, <variable(s)> etc aren't counted but only the executable script is. Either option would also make it easier to deal with this kind of issue.

(And in case you were thinking of suggesting it.. no, I can't split it up in different plugins.:) )
Australia Forum Administrator #1
It is fiddly to get this right, because included files can include other files.

I have made an attempt in version 4.08, which keeps a copy of the script in memory (that is, the concenated version of all the scripts from all the included files), and attempts to show the line in error, and surrounding lines.

For example, using Lua scripting:


[string "Script file"]:108: bad argument #3 to 'ColourNote' (string expected, got no value)
stack traceback:
        [C]: in function 'ColourNote'
        [string "Script file"]:108: in main chunk
105 : 
106 : require "tprint"
107 : 
108*: ColourNote ("aa")
109 : 
110 : 
111 : function my_trigger (name, line, wildcards, styles)


This requires you to be "noting" script errors to the output window.

Notice how line 108 has an asterisk next to it to indicate this is the "problem" line. I have shown a few before and after, as some compilers notice an error on the next line (eg. a missing semicolon on the previous line). Plus a few more lines puts the thing in context a bit more.

Another example, introducing a syntax error into the VBscript chat plugin:


Script error
Plugin: Chat (called from world: SMAUG)
Execution of line 11 column 4
Immediate execution
Syntax error
Line in error: 
asd;lkajsdf;adfsasdf
7 :   end if
8 : 
9 : end function
10 : 
11*: asd;lkajsdf;adfsasdf
12 : 
13 : sub chatdetails (id)

Amended on Wed 09 May 2007 04:58 AM by Nick Gammon
Netherlands #2
I figured it be difficult, that's why I suggested a 'workable' version and one if you were [interested in a challenge/perfectionistic/in for a lot of pain]*)

Anyhow, thank you a lot! Right now, I have like 30 files, all of which get included in one way or another, and this will make debugging far easier!

However, one supplemental request. MUSHclient has always been pretty 'lean' and I recall features being rejected simply because of the amount of overhead they'd give. I can imagine that a world with 20 plugins loaded can actually get quite resource intensive. How about a global/world setting that allows people with less memory to 'not' store it in memory and thus not Note() the linenumbers on screen when an error happens, either?

It is nothing that I need since my computer is quite fast enough after receiving a memory upgrade recently. But in a simple world window pre-upgrade, I could clearly notice the difference between say, 10,000 lines scrollback and 20,000 lines scrollback.

*) choose the option that is most appropriate. :)
Australia Forum Administrator #3
In plugins, the source was already stored, so it doesn't make any difference. I had to add storing the "main" world source, but I doubt many people would have huge main script files these days, since plugins are better suited to that.

Right now you can type:


/Debug "plugins"


This will list all plugins including their source. So with a bit of copy and paste into an editor that supports line numbers, you could work out where line 7122 is (or mouse over the lines to get the little popup window which gives line numbers, and do a bit of subtraction). If you have lots of plugins then this technique might very quickly fill up your output window.