Mythruna

Modder's Workbench => Scripting => Topic started by: Michael on February 16, 2015, 11:29:44 AM



Title: What is Script15?
Post by: Michael on February 16, 2015, 11:29:44 AM
In errors while programming, you'll run into "Script15"

When you run this code:
Code:
try {
File f = new File("ClassName.TEST");
f.createNewFile();
BufferedWriter writer = new BufferedWriter(new FileWriter(f));
writer.write(getClass().getSimpleName());
writer.close();
} catch (IOException e) {
;
}
The result is "Script15"

In essence, what is "Script15", and what is its purpose?


Title: Re: What is Script15?
Post by: pspeed on February 16, 2015, 02:07:48 PM
Script15 is the class name of the 15th script that was loaded.  I was going to say that I think I keep a mapping of the classes to that actual names for error reporting but I just remember that's only in the new engine.

Because I use jsr223 support in Java to load groovy scripts, groovy doesn't know what the original script file was called and so just generates a name for the compiled class (groovy is Java after all and so must end up as a .class even if only in memory).  In the new engine, I go through some level of pain to keep track of the loaded script name and associate with the compiled script.

Anyway, it makes it harder to debug for sure.


Title: Re: What is Script15?
Post by: Michael on February 16, 2015, 02:13:01 PM
Ok, thank you.