using System; using System.Collections.Generic; using System.Text; namespace OpenSim.Scripting { public class ScriptManager { List scripts = new List(); OpenSim.Region.Scenes.Scene scene; Dictionary compilers = new Dictionary(); private void LoadFromCompiler(Dictionary compiledscripts) { foreach (KeyValuePair script in compiledscripts) { ScriptInfo scriptInfo = new ScriptInfo(scene); // Since each script could potentially corrupt their access with a stray assignment, making a new one for each script. OpenSim.Framework.Console.MainLog.Instance.Verbose("Loading " + script.Key); script.Value.Initialise(scriptInfo); scripts.Add(script.Value); } OpenSim.Framework.Console.MainLog.Instance.Verbose("Finished loading " + compiledscripts.Count.ToString() + " script(s)"); } public ScriptManager(OpenSim.Region.Scenes.Scene world) { scene = world; // Defualt Engines CSharpScriptEngine csharpCompiler = new CSharpScriptEngine(); compilers.Add(csharpCompiler.fileExt(),csharpCompiler); } public void Compile(string filename) { foreach (KeyValuePair compiler in compilers) { if (filename.EndsWith(compiler.Key)) { LoadFromCompiler(compiler.Value.compile(filename)); break; } } } public void RunScriptCmd(string[] args) { switch (args[0]) { case "load": Compile(args[1]); break; default: OpenSim.Framework.Console.MainLog.Instance.Error("Unknown script command"); break; } } } interface IScriptCompiler { Dictionary compile(string filename); string fileExt(); } }