Script Not Loading on Connect

Post Reply
Jor'Mox
Posts: 1146
Joined: Wed Apr 03, 2013 2:19 am

Script Not Loading on Connect

Post by Jor'Mox »

I have a script that, for whatever reason, doesn't seem to get loaded when I connect to the game the first time. To get it to load, I have to open the script pane, select the script, and then either click the save button, of switch to another script. No errors appear on connect, and even putting a display line as the very first line of code in the script still doesn't result in anything happening. Any ideas what is going on, and how to remedy it?

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: Script Not Loading on Connect

Post by Vadi »

I'm not sure off the top of my head. Is it at the root level or inside any other scripts?

Jor'Mox
Posts: 1146
Joined: Wed Apr 03, 2013 2:19 am

Re: Script Not Loading on Connect

Post by Jor'Mox »

It is at root level. And I finally managed to get it loading automatically, though I'm not certain WHY it was behaving the way it was. First, I had to fix a mistake of mine, in which I accessed a public variable declared in a second script as part of the declarations for this script, without declaring the variable itself. So since this script was positioned above the script that declared the variable, it didn't exist for the table access to be performed (which should have produced an error, but didn't, and should have allowed code prior to the error to be executed, and it wasn't). Secondly, I had to "activate" the script, which I think I had deactivated previously in an attempt to try to discern what was going on.

So in summary, it seems that deactivated scripts aren't automatically loaded on connect (which seems reasonable), and activated scripts in which executing the code results in an error are also not loaded, and no error is sent to the error pane. The second part is, in my view, less than ideal, as it makes determining what is going wrong much more difficult to discern. My particular error was relatively easy to find and correct, but I think it would make more sense for there to be at least some message generated when a script fails to load, preferably one that references the source of the problem.

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: Script Not Loading on Connect

Post by Vadi »

Remember how Mudlet shows a notification if the script has an error on loading when you save? Well that is what also happens when the script is being loaded - and when you click on it, because the variable is declared, the notification dissapears.

This does catch out people now and then. What about instead of showing a notification that the person will never see, errors are logged to the error console when Mudlet is starting up?

Jor'Mox
Posts: 1146
Joined: Wed Apr 03, 2013 2:19 am

Re: Script Not Loading on Connect

Post by Jor'Mox »

I think putting those errors in the error console would make a lot of sense, and definitely help people figure out what was going on in such situations.

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: Script Not Loading on Connect

Post by Vadi »

Yeah. Once Mudlet is loaded, it'll go back to notifications, since we don't want the error console spammed with all of the syntax errors people can make while coding.

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: Script Not Loading on Connect

Post by Vadi »

Hm, no, it's that trivial. If the user has a syntax error in their script, they will not run into this situation - the error notification will always be there - and now their scripts will needlessly spam the error console on every load.

Jor'Mox
Posts: 1146
Joined: Wed Apr 03, 2013 2:19 am

Re: Script Not Loading on Connect

Post by Jor'Mox »

I guess the only real issue is someone trying to reference a global function or table that doesn't exist at the time the script is read, but exists once other scripts are read in, as that sort of error won't ever show up when a person tries to see what is wrong with the script. If you don't want to display these errors in the error panel, perhaps there could be a way to check for exactly this sort of problem in a script. At a minimum, perhaps the "bug" icon could be shown for the script just as it does for one that has a syntax error, at least until they open the script.

Post Reply