J Lothian wrote:
Justin,
Thanks for pointing me in a direction, this was -very- helpful. It
wasn't nearly as straightforward as I was expecting, but it did give me
the opportunity/excuse to get my hands dirty and dig into the projects
and code a bit. I'm going to document the process a bit here, so it
gets archived for future reference. I'm pretty sure I've narrowed down
the steps needed.
The actual project that needs the assembly reference added to it is
OpenSim.Region.ScriptEngine.Shared.CodeTools, but this is just the
start. This gets the assembly detectable by the compiler. The next
step is adding the reference to the script being compiled. In
OpenSim.Region.ScriptEngine.Shared.CodeTools.Compiler (Compiler.cs), in
the function CompileFromDotNetText, there is a section where
ReferencedAssemblies are added to the compiler as parameters, and the
assembly needs to be added here as well. For example, to add a standard
library, the following line would be used:
parameters.ReferencedAssemblies.Add("System.dll");
Which, it turns out, I needed to do, as System.dll isn't added by
default, and our test script included a try/catch where Exception was
not detected as a type. To add something like the MySql dll that comes
with OpenSim, it would look like this:
parameters.ReferencedAssemblies.Add(
Path.Combine(rootPath,"MySql.Data.dll"));The script engine automatically
wraps scripts in boilerplate code to put them inside a class and make
them compilable. This has the side-effect of making "using" or "import"
statements inside scripts impossible, so these also need to be added to
the code.
For example, if your script is C#, then the function to alter is
CreateCSCompilerScript (in the same Compile.cs), adding the using
statement to the list inside this function.
If I get the chance later this summer, I may try to develop a more
robust system that attempts to (at the very least) detect the default
mono/.net libraries and automatically adjust this boilerplate to include
them...
Again, thanks for the help!
Glad that was of some use! Would very much look forward to a boilerplate
adjuster - being able to include extra libraries from OpenSim C# 'scripts'
would be really useful.
Also, it would be great if you could copy the above into a new wiki page off
http://opensimulator.org/wiki/Developer_Documentation#Scripting. Things tend
to stay a little bit more visible there. Thanks!
--
Justin Clark-Casey (justincc)
http://justincc.org
http://twitter.com/justincc
_______________________________________________
Opensim-dev mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/opensim-dev