* Now sending manager, host and root host to Script in constructor.
* Changed how Script accesses World * Implemented llSay, llWhisper and llShout * Added SetText() to IScriptHost, implemented llText * Minor renamings to conform with code conventionsafrisby
parent
cb90510e16
commit
e53d680d41
|
@ -130,5 +130,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
public virtual void LandRenegerated()
|
public virtual void LandRenegerated()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public abstract void SetText(string text, Vector3 color, double alpha);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -715,5 +715,10 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
{
|
{
|
||||||
OnPrimCountTainted();
|
OnPrimCountTainted();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void SetText(string text, Vector3 color, double alpha)
|
||||||
|
{
|
||||||
|
throw new Exception("The method or operation is not implemented.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -311,5 +311,9 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
client.OutPacket(proper);
|
client.OutPacket(proper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void SetText(string text, Axiom.Math.Vector3 color, double alpha)
|
||||||
|
{
|
||||||
|
throw new System.Exception("The method or operation is not implemented.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -949,5 +949,10 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void SetText(string text, Vector3 color, double alpha)
|
||||||
|
{
|
||||||
|
Text = text;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -576,6 +576,11 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
public virtual void OnGrab(LLVector3 offsetPos, IClientAPI remoteClient)
|
public virtual void OnGrab(LLVector3 offsetPos, IClientAPI remoteClient)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetText(string text, Vector3 color, double alpha)
|
||||||
|
{
|
||||||
|
Text = text;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -690,6 +690,11 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void SetText(string text, Vector3 color, double alpha)
|
||||||
|
{
|
||||||
|
throw new Exception("The method or operation is not implemented.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,5 +10,6 @@ namespace OpenSim.Region.Environment.Scenes.Scripting
|
||||||
string Name { get; }
|
string Name { get; }
|
||||||
LLUUID UUID { get; }
|
LLUUID UUID { get; }
|
||||||
LLVector3 AbsolutePosition { get; }
|
LLVector3 AbsolutePosition { get; }
|
||||||
|
void SetText(string text, Axiom.Math.Vector3 color, double alpha);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,5 +22,10 @@ namespace OpenSim.Region.Environment.Scenes.Scripting
|
||||||
{
|
{
|
||||||
get { return m_pos; }
|
get { return m_pos; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetText(string text, Axiom.Math.Vector3 color, double alpha)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Tried to SetText [{0}] on NullScriptHost", text);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,13 +45,13 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
||||||
static public void SendToDebug(string Message)
|
static public void SendToDebug(string Message)
|
||||||
{
|
{
|
||||||
//if (Debug == true)
|
//if (Debug == true)
|
||||||
mySE.m_logger.Verbose("ScriptEngine", "Debug: " + Message);
|
mySE.Log.Verbose("ScriptEngine", "Debug: " + Message);
|
||||||
//SendToDebugEvent("\r\n" + DateTime.Now.ToString("[HH:mm:ss] ") + Message);
|
//SendToDebugEvent("\r\n" + DateTime.Now.ToString("[HH:mm:ss] ") + Message);
|
||||||
}
|
}
|
||||||
static public void SendToLog(string Message)
|
static public void SendToLog(string Message)
|
||||||
{
|
{
|
||||||
//if (Debug == true)
|
//if (Debug == true)
|
||||||
mySE.m_logger.Verbose("ScriptEngine", "LOG: " + Message);
|
mySE.Log.Verbose("ScriptEngine", "LOG: " + Message);
|
||||||
//SendToLogEvent("\r\n" + DateTime.Now.ToString("[HH:mm:ss] ") + Message);
|
//SendToLogEvent("\r\n" + DateTime.Now.ToString("[HH:mm:ss] ") + Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -229,7 +229,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
|
||||||
// Add namespace, class name and inheritance
|
// Add namespace, class name and inheritance
|
||||||
Return = "namespace SecondLife {\r\n";
|
Return = "namespace SecondLife {\r\n";
|
||||||
Return += "public class Script : OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass {\r\n";
|
Return += "public class Script : OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass {\r\n";
|
||||||
Return += "public Script( OpenSim.Region.Environment.Scenes.Scripting.IScriptHost host ) : base( host ) { }\r\n";
|
Return += @"
|
||||||
|
public Script(
|
||||||
|
OpenSim.Region.ScriptEngine.DotNetEngine.ScriptManager manager,
|
||||||
|
OpenSim.Region.Environment.Scenes.Scripting.IScriptHost host,
|
||||||
|
OpenSim.Region.Environment.Scenes.Scripting.IScriptHost root ) : base( manager, host, root ) { }"+"\r\n";
|
||||||
Return += Script;
|
Return += Script;
|
||||||
Return += "} }\r\n";
|
Return += "} }\r\n";
|
||||||
|
|
||||||
|
|
|
@ -12,20 +12,27 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
|
||||||
public class LSL_BaseClass : LSL_BuiltIn_Commands_Interface
|
public class LSL_BaseClass : LSL_BuiltIn_Commands_Interface
|
||||||
{
|
{
|
||||||
public string State = "default";
|
public string State = "default";
|
||||||
internal OpenSim.Region.Environment.Scenes.Scene World;
|
|
||||||
private System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
|
private System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
|
||||||
|
|
||||||
IScriptHost m_host;
|
protected ScriptManager m_manager;
|
||||||
|
protected IScriptHost m_host;
|
||||||
|
protected IScriptHost m_root;
|
||||||
|
|
||||||
public LSL_BaseClass( IScriptHost host )
|
public LSL_BaseClass(ScriptManager manager, IScriptHost host, IScriptHost root)
|
||||||
{
|
{
|
||||||
|
m_manager = manager;
|
||||||
m_host = host;
|
m_host = host;
|
||||||
|
m_root = root;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Start(OpenSim.Region.Environment.Scenes.Scene _World, string FullScriptID)
|
public Scene World
|
||||||
{
|
{
|
||||||
World = _World;
|
get { return m_manager.World; }
|
||||||
MainLog.Instance.Notice( "ScriptEngine", "LSL_BaseClass.Start() called. FullScriptID: " + FullScriptID + ": Hosted by [" + m_host.Name + ":" + m_host.UUID + "@"+m_host.AbsolutePosition +"]");
|
}
|
||||||
|
|
||||||
|
public void Start(string FullScriptID)
|
||||||
|
{
|
||||||
|
MainLog.Instance.Notice("ScriptEngine", "LSL_BaseClass.Start() called. FullScriptID: " + FullScriptID + ": Hosted by [" + m_host.Name + ":" + m_host.UUID + "@" + m_host.AbsolutePosition + "]");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -54,12 +61,15 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
|
||||||
public Axiom.Math.Vector3 llRot2Left(Axiom.Math.Quaternion r) { return new Axiom.Math.Vector3(); }
|
public Axiom.Math.Vector3 llRot2Left(Axiom.Math.Quaternion r) { return new Axiom.Math.Vector3(); }
|
||||||
public Axiom.Math.Vector3 llRot2Up(Axiom.Math.Quaternion r) { return new Axiom.Math.Vector3(); }
|
public Axiom.Math.Vector3 llRot2Up(Axiom.Math.Quaternion r) { return new Axiom.Math.Vector3(); }
|
||||||
public Axiom.Math.Quaternion llRotBetween(Axiom.Math.Vector3 start, Axiom.Math.Vector3 end) { return new Axiom.Math.Quaternion(); }
|
public Axiom.Math.Quaternion llRotBetween(Axiom.Math.Vector3 start, Axiom.Math.Vector3 end) { return new Axiom.Math.Quaternion(); }
|
||||||
|
|
||||||
public void llWhisper(int channelID, string text)
|
public void llWhisper(int channelID, string text)
|
||||||
{
|
{
|
||||||
//Common.SendToDebug("INTERNAL FUNCTION llWhisper(" + channelID + ", \"" + text + "\");");
|
//Common.SendToDebug("INTERNAL FUNCTION llWhisper(" + channelID + ", \"" + text + "\");");
|
||||||
Console.WriteLine("llWhisper Channel " + channelID + ", Text: \"" + text + "\"");
|
Console.WriteLine("llWhisper Channel " + channelID + ", Text: \"" + text + "\"");
|
||||||
//type for whisper is 0
|
//type for whisper is 0
|
||||||
//World.SimChat(enc.GetBytes(text), 0, World.Objects[World.ConvertLocalIDToFullID(MY_OBJECT_ID)], MY_OBJECT_NAME, World.Objects[World.ConvertLocalIDToFullID(MY_OBJECT_ID)]);
|
World.SimChat(Helpers.StringToField(text),
|
||||||
|
0, m_host.AbsolutePosition, m_host.Name, m_host.UUID);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
//public void llSay(int channelID, string text)
|
//public void llSay(int channelID, string text)
|
||||||
|
@ -70,18 +80,16 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
|
||||||
Console.WriteLine("llSay Channel " + channelID + ", Text: \"" + text + "\"");
|
Console.WriteLine("llSay Channel " + channelID + ", Text: \"" + text + "\"");
|
||||||
//type for say is 1
|
//type for say is 1
|
||||||
|
|
||||||
LLVector3 fromPos = m_host.AbsolutePosition; // Position of parent
|
World.SimChat(Helpers.StringToField(text),
|
||||||
string fromName = m_host.Name; // Name of script parent
|
1, m_host.AbsolutePosition, m_host.Name, m_host.UUID);
|
||||||
LLUUID fromUUID = m_host.UUID; // UUID of parent
|
|
||||||
|
|
||||||
World.SimChat( Helpers.StringToField( text ), 1, fromPos, fromName, fromUUID );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void llShout(int channelID, string text)
|
public void llShout(int channelID, string text)
|
||||||
{
|
{
|
||||||
Console.WriteLine("llShout Channel " + channelID + ", Text: \"" + text + "\"");
|
Console.WriteLine("llShout Channel " + channelID + ", Text: \"" + text + "\"");
|
||||||
//type for shout is 2
|
//type for shout is 2
|
||||||
//World.SimChat(enc.GetBytes(text), 2, World.Objects[World.ConvertLocalIDToFullID(MY_OBJECT_ID)], MY_OBJECT_NAME, World.Objects[World.ConvertLocalIDToFullID(MY_OBJECT_ID)]);
|
World.SimChat(Helpers.StringToField(text),
|
||||||
|
2, m_host.AbsolutePosition, m_host.Name, m_host.UUID);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,8 +128,12 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
|
||||||
public string llGetTexture(int face) { return ""; }
|
public string llGetTexture(int face) { return ""; }
|
||||||
public void llSetPos(Axiom.Math.Vector3 pos) { return; }
|
public void llSetPos(Axiom.Math.Vector3 pos) { return; }
|
||||||
|
|
||||||
|
public Axiom.Math.Vector3 llGetPos()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException("llGetPos");
|
||||||
|
// return m_host.AbsolutePosition;
|
||||||
|
}
|
||||||
|
|
||||||
public Axiom.Math.Vector3 llGetPos() { return new Axiom.Math.Vector3(); }
|
|
||||||
public Axiom.Math.Vector3 llGetLocalPos() { return new Axiom.Math.Vector3(); }
|
public Axiom.Math.Vector3 llGetLocalPos() { return new Axiom.Math.Vector3(); }
|
||||||
public void llSetRot(Axiom.Math.Quaternion rot) { }
|
public void llSetRot(Axiom.Math.Quaternion rot) { }
|
||||||
public Axiom.Math.Quaternion llGetRot() { return new Axiom.Math.Quaternion(); }
|
public Axiom.Math.Quaternion llGetRot() { return new Axiom.Math.Quaternion(); }
|
||||||
|
@ -214,7 +226,12 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
|
||||||
public double llGetEnergy() { return 1.0f; }
|
public double llGetEnergy() { return 1.0f; }
|
||||||
public void llGiveInventory(string destination, string inventory) { }
|
public void llGiveInventory(string destination, string inventory) { }
|
||||||
public void llRemoveInventory(string item) { }
|
public void llRemoveInventory(string item) { }
|
||||||
public void llSetText(string text, Axiom.Math.Vector3 color, double alpha) { }
|
|
||||||
|
public void llSetText(string text, Axiom.Math.Vector3 color, double alpha)
|
||||||
|
{
|
||||||
|
m_host.SetText(text, color, alpha );
|
||||||
|
}
|
||||||
|
|
||||||
public double llWater(Axiom.Math.Vector3 offset) { return 0; }
|
public double llWater(Axiom.Math.Vector3 offset) { return 0; }
|
||||||
public void llPassTouches(int pass) { }
|
public void llPassTouches(int pass) { }
|
||||||
public string llRequestAgentData(string id, int data) { return ""; }
|
public string llRequestAgentData(string id, int data) { return ""; }
|
||||||
|
@ -298,7 +315,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
|
||||||
public Axiom.Math.Vector3 llGroundContour(Axiom.Math.Vector3 offset) { return new Axiom.Math.Vector3(); }
|
public Axiom.Math.Vector3 llGroundContour(Axiom.Math.Vector3 offset) { return new Axiom.Math.Vector3(); }
|
||||||
public int llGetAttached() { return 0; }
|
public int llGetAttached() { return 0; }
|
||||||
public int llGetFreeMemory() { return 0; }
|
public int llGetFreeMemory() { return 0; }
|
||||||
public string llGetRegionName() { return World.RegionInfo.RegionName; }
|
public string llGetRegionName() { return m_manager.RegionName; }
|
||||||
public double llGetRegionTimeDilation() { return 1.0f; }
|
public double llGetRegionTimeDilation() { return 1.0f; }
|
||||||
public double llGetRegionFPS() { return 10.0f; }
|
public double llGetRegionFPS() { return 10.0f; }
|
||||||
public void llParticleSystem(List<Object> rules) { }
|
public void llParticleSystem(List<Object> rules) { }
|
||||||
|
@ -316,6 +333,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
|
||||||
public void llSetTouchText(string text)
|
public void llSetTouchText(string text)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void llSetSitText(string text)
|
public void llSetSitText(string text)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -347,8 +365,18 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
|
||||||
public double llLog(double val) { return (double)Math.Log(val); }
|
public double llLog(double val) { return (double)Math.Log(val); }
|
||||||
public List<string> llGetAnimationList(string id) { return new List<string>(); }
|
public List<string> llGetAnimationList(string id) { return new List<string>(); }
|
||||||
public void llSetParcelMusicURL(string url) { }
|
public void llSetParcelMusicURL(string url) { }
|
||||||
public Axiom.Math.Vector3 llGetRootPosition() { return new Axiom.Math.Vector3(); }
|
|
||||||
public Axiom.Math.Quaternion llGetRootRotation() { return new Axiom.Math.Quaternion(); }
|
public Axiom.Math.Vector3 llGetRootPosition()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException("llGetRootPosition");
|
||||||
|
//return m_root.AbsolutePosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Axiom.Math.Quaternion llGetRootRotation()
|
||||||
|
{
|
||||||
|
return new Axiom.Math.Quaternion();
|
||||||
|
}
|
||||||
|
|
||||||
public string llGetObjectDesc() { return ""; }
|
public string llGetObjectDesc() { return ""; }
|
||||||
public void llSetObjectDesc(string desc) { }
|
public void llSetObjectDesc(string desc) { }
|
||||||
public string llGetCreator() { return ""; }
|
public string llGetCreator() { return ""; }
|
||||||
|
|
|
@ -48,7 +48,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
||||||
// TODO: ADD SERVER HOOK TO LOAD A SCRIPT THROUGH myScriptEngine.ScriptManager
|
// TODO: ADD SERVER HOOK TO LOAD A SCRIPT THROUGH myScriptEngine.ScriptManager
|
||||||
|
|
||||||
// Hook up a test event to our test form
|
// Hook up a test event to our test form
|
||||||
myScriptEngine.m_logger.Verbose("ScriptEngine", "EventManager Hooking up dummy-event: touch_start");
|
myScriptEngine.Log.Verbose("ScriptEngine", "EventManager Hooking up dummy-event: touch_start");
|
||||||
// TODO: REPLACE THIS WITH A REAL TOUCH_START EVENT IN SERVER
|
// TODO: REPLACE THIS WITH A REAL TOUCH_START EVENT IN SERVER
|
||||||
myScriptEngine.World.EventManager.OnObjectGrab += new OpenSim.Region.Environment.Scenes.EventManager.ObjectGrabDelegate(touch_start);
|
myScriptEngine.World.EventManager.OnObjectGrab += new OpenSim.Region.Environment.Scenes.EventManager.ObjectGrabDelegate(touch_start);
|
||||||
//myScriptEngine.World.touch_start += new TempWorldInterfaceEventDelegates.touch_start(touch_start);
|
//myScriptEngine.World.touch_start += new TempWorldInterfaceEventDelegates.touch_start(touch_start);
|
||||||
|
|
|
@ -74,7 +74,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
myScriptEngine.m_logger.Verbose("ScriptEngine", "EventQueueManager Exception killing worker thread: " + e.ToString());
|
myScriptEngine.Log.Verbose("ScriptEngine", "EventQueueManager Exception killing worker thread: " + e.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Todo: Clean up our queues
|
// Todo: Clean up our queues
|
||||||
|
@ -105,7 +105,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
||||||
}
|
}
|
||||||
catch (ThreadAbortException tae)
|
catch (ThreadAbortException tae)
|
||||||
{
|
{
|
||||||
myScriptEngine.m_logger.Verbose("ScriptEngine", "EventQueueManager Worker thread killed: " + tae.Message);
|
myScriptEngine.Log.Verbose("ScriptEngine", "EventQueueManager Worker thread killed: " + tae.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using OpenSim.Framework.Console;
|
||||||
|
|
||||||
namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
||||||
{
|
{
|
||||||
|
@ -42,7 +43,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
||||||
internal EventManager myEventManager; // Handles and queues incoming events from OpenSim
|
internal EventManager myEventManager; // Handles and queues incoming events from OpenSim
|
||||||
internal EventQueueManager myEventQueueManager; // Executes events
|
internal EventQueueManager myEventQueueManager; // Executes events
|
||||||
internal ScriptManager myScriptManager; // Load, unload and execute scripts
|
internal ScriptManager myScriptManager; // Load, unload and execute scripts
|
||||||
internal OpenSim.Framework.Console.LogBase m_logger;
|
|
||||||
|
private OpenSim.Framework.Console.LogBase m_log;
|
||||||
|
|
||||||
public ScriptEngine()
|
public ScriptEngine()
|
||||||
{
|
{
|
||||||
|
@ -50,10 +52,15 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
||||||
Common.mySE = this;
|
Common.mySE = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LogBase Log
|
||||||
|
{
|
||||||
|
get { return m_log; }
|
||||||
|
}
|
||||||
|
|
||||||
public void InitializeEngine(OpenSim.Region.Environment.Scenes.Scene Sceneworld, OpenSim.Framework.Console.LogBase logger)
|
public void InitializeEngine(OpenSim.Region.Environment.Scenes.Scene Sceneworld, OpenSim.Framework.Console.LogBase logger)
|
||||||
{
|
{
|
||||||
World = Sceneworld;
|
World = Sceneworld;
|
||||||
m_logger = logger;
|
m_log = logger;
|
||||||
|
|
||||||
//m_logger.Status("ScriptEngine", "InitializeEngine");
|
//m_logger.Status("ScriptEngine", "InitializeEngine");
|
||||||
|
|
||||||
|
@ -75,7 +82,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
||||||
[Obsolete("!!!FOR DEBUGGING ONLY!!!")]
|
[Obsolete("!!!FOR DEBUGGING ONLY!!!")]
|
||||||
public void StartScript(string ScriptID, string ObjectID)
|
public void StartScript(string ScriptID, string ObjectID)
|
||||||
{
|
{
|
||||||
m_logger.Status("ScriptEngine", "DEBUG FUNCTION: StartScript: " + ScriptID);
|
Log.Status("ScriptEngine", "DEBUG FUNCTION: StartScript: " + ScriptID);
|
||||||
myScriptManager.StartScript(ScriptID, ObjectID);
|
myScriptManager.StartScript(ScriptID, ObjectID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using OpenSim.Region.Environment.Scenes;
|
||||||
using OpenSim.Region.Environment.Scenes.Scripting;
|
using OpenSim.Region.Environment.Scenes.Scripting;
|
||||||
|
|
||||||
namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
||||||
|
@ -40,19 +41,26 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
||||||
/// Compiles them if necessary
|
/// Compiles them if necessary
|
||||||
/// Execute functions for EventQueueManager
|
/// Execute functions for EventQueueManager
|
||||||
/// </summary>
|
/// </summary>
|
||||||
class ScriptManager
|
public class ScriptManager
|
||||||
{
|
{
|
||||||
|
|
||||||
private ScriptEngine myScriptEngine;
|
private ScriptEngine m_scriptEngine;
|
||||||
public ScriptManager(ScriptEngine _ScriptEngine)
|
public ScriptManager(ScriptEngine scriptEngine)
|
||||||
{
|
{
|
||||||
myScriptEngine = _ScriptEngine;
|
m_scriptEngine = scriptEngine;
|
||||||
myScriptEngine.m_logger.Verbose("ScriptEngine", "ScriptManager Start");
|
m_scriptEngine.Log.Verbose("ScriptEngine", "ScriptManager Start");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Object<string, Script<string, script>>
|
// Object<string, Script<string, script>>
|
||||||
internal Dictionary<string, Dictionary<string, OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass>> Scripts = new Dictionary<string, Dictionary<string, OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass>>();
|
internal Dictionary<string, Dictionary<string, OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass>> Scripts = new Dictionary<string, Dictionary<string, OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass>>();
|
||||||
|
public Scene World
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_scriptEngine.World;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
internal Dictionary<string, OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass>.KeyCollection GetScriptKeys(string ObjectID)
|
internal Dictionary<string, OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass>.KeyCollection GetScriptKeys(string ObjectID)
|
||||||
|
@ -88,7 +96,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
||||||
{
|
{
|
||||||
// Create object if it doesn't exist
|
// Create object if it doesn't exist
|
||||||
if (Scripts.ContainsKey(ObjectID) == false)
|
if (Scripts.ContainsKey(ObjectID) == false)
|
||||||
|
{
|
||||||
Scripts.Add(ObjectID, new Dictionary<string, OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass>());
|
Scripts.Add(ObjectID, new Dictionary<string, OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass>());
|
||||||
|
}
|
||||||
|
|
||||||
// Delete script if it exists
|
// Delete script if it exists
|
||||||
Dictionary<string, OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass> Obj;
|
Dictionary<string, OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass> Obj;
|
||||||
|
@ -108,7 +118,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
||||||
/// <param name="ObjectID"></param>
|
/// <param name="ObjectID"></param>
|
||||||
public void StartScript(string ScriptID, string ObjectID)
|
public void StartScript(string ScriptID, string ObjectID)
|
||||||
{
|
{
|
||||||
myScriptEngine.m_logger.Verbose("ScriptEngine", "ScriptManager StartScript: ScriptID: " + ScriptID + ", ObjectID: " + ObjectID);
|
m_scriptEngine.Log.Verbose("ScriptEngine", "ScriptManager StartScript: ScriptID: " + ScriptID + ", ObjectID: " + ObjectID);
|
||||||
|
|
||||||
// We will initialize and start the script.
|
// We will initialize and start the script.
|
||||||
// It will be up to the script itself to hook up the correct events.
|
// It will be up to the script itself to hook up the correct events.
|
||||||
|
@ -130,7 +140,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
||||||
case ".txt":
|
case ".txt":
|
||||||
case ".lsl":
|
case ".lsl":
|
||||||
case ".cs":
|
case ".cs":
|
||||||
myScriptEngine.m_logger.Verbose("ScriptEngine", "ScriptManager Script is CS/LSL, compiling to .Net Assembly");
|
m_scriptEngine.Log.Verbose("ScriptEngine", "ScriptManager Script is CS/LSL, compiling to .Net Assembly");
|
||||||
// Create a new instance of the compiler (currently we don't want reuse)
|
// Create a new instance of the compiler (currently we don't want reuse)
|
||||||
OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.Compiler LSLCompiler = new OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.Compiler();
|
OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.Compiler LSLCompiler = new OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.Compiler();
|
||||||
// Compile
|
// Compile
|
||||||
|
@ -142,7 +152,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
myScriptEngine.m_logger.Verbose("ScriptEngine", "Compilation done");
|
m_scriptEngine.Log.Verbose("ScriptEngine", "Compilation done");
|
||||||
// * Insert yield into code
|
// * Insert yield into code
|
||||||
FileName = ProcessYield(FileName);
|
FileName = ProcessYield(FileName);
|
||||||
|
|
||||||
|
@ -152,7 +162,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
||||||
// * Load and start script, for now with dummy host
|
// * Load and start script, for now with dummy host
|
||||||
|
|
||||||
//OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO.LSL_BaseClass Script = LoadAndInitAssembly(FreeAppDomain, FileName);
|
//OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO.LSL_BaseClass Script = LoadAndInitAssembly(FreeAppDomain, FileName);
|
||||||
OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass Script = LoadAndInitAssembly(FreeAppDomain, FileName, new NullScriptHost() );
|
IScriptHost host = new NullScriptHost();
|
||||||
|
IScriptHost root = host;
|
||||||
|
|
||||||
|
OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass Script = LoadAndInitAssembly(FreeAppDomain, FileName, host, root );
|
||||||
string FullScriptID = ScriptID + "." + ObjectID;
|
string FullScriptID = ScriptID + "." + ObjectID;
|
||||||
// Add it to our temporary active script keeper
|
// Add it to our temporary active script keeper
|
||||||
//Scripts.Add(FullScriptID, Script);
|
//Scripts.Add(FullScriptID, Script);
|
||||||
|
@ -164,12 +177,12 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
||||||
// Start the script - giving it BuiltIns
|
// Start the script - giving it BuiltIns
|
||||||
//myScriptEngine.m_logger.Verbose("ScriptEngine", "ScriptManager initializing script, handing over private builtin command interface");
|
//myScriptEngine.m_logger.Verbose("ScriptEngine", "ScriptManager initializing script, handing over private builtin command interface");
|
||||||
|
|
||||||
Script.Start(myScriptEngine.World, ScriptID);
|
Script.Start( ScriptID );
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
myScriptEngine.m_logger.Error("ScriptEngine", "Exception loading script \"" + FileName + "\": " + e.ToString());
|
m_scriptEngine.Log.Error("ScriptEngine", "Exception loading script \"" + FileName + "\": " + e.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -192,7 +205,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
||||||
/// <param name="FreeAppDomain">AppDomain to load script into</param>
|
/// <param name="FreeAppDomain">AppDomain to load script into</param>
|
||||||
/// <param name="FileName">FileName of script assembly (.dll)</param>
|
/// <param name="FileName">FileName of script assembly (.dll)</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass LoadAndInitAssembly(AppDomain FreeAppDomain, string FileName, IScriptHost host)
|
private OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass LoadAndInitAssembly(AppDomain FreeAppDomain, string FileName, IScriptHost host, IScriptHost root)
|
||||||
{
|
{
|
||||||
//myScriptEngine.m_logger.Verbose("ScriptEngine", "ScriptManager Loading Assembly " + FileName);
|
//myScriptEngine.m_logger.Verbose("ScriptEngine", "ScriptManager Loading Assembly " + FileName);
|
||||||
// Load .Net Assembly (.dll)
|
// Load .Net Assembly (.dll)
|
||||||
|
@ -231,7 +244,13 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
||||||
//{
|
//{
|
||||||
//}
|
//}
|
||||||
|
|
||||||
object[] args = new object[] { host };
|
// Create constructor arguments
|
||||||
|
object[] args = new object[]
|
||||||
|
{
|
||||||
|
this,
|
||||||
|
host,
|
||||||
|
root
|
||||||
|
};
|
||||||
|
|
||||||
return (OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass)Activator.CreateInstance(t, args );
|
return (OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass)Activator.CreateInstance(t, args );
|
||||||
|
|
||||||
|
@ -240,13 +259,13 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
||||||
|
|
||||||
internal void ExecuteFunction(string ObjectID, string ScriptID, string FunctionName, object[] args)
|
internal void ExecuteFunction(string ObjectID, string ScriptID, string FunctionName, object[] args)
|
||||||
{
|
{
|
||||||
myScriptEngine.m_logger.Verbose("ScriptEngine", "Executing Function ObjectID: " + ObjectID + ", ScriptID: " + ScriptID + ", FunctionName: " + FunctionName);
|
m_scriptEngine.Log.Verbose("ScriptEngine", "Executing Function ObjectID: " + ObjectID + ", ScriptID: " + ScriptID + ", FunctionName: " + FunctionName);
|
||||||
OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass Script = myScriptEngine.myScriptManager.GetScript(ObjectID, ScriptID);
|
OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass Script = m_scriptEngine.myScriptManager.GetScript(ObjectID, ScriptID);
|
||||||
|
|
||||||
Type type = Script.GetType();
|
Type type = Script.GetType();
|
||||||
|
|
||||||
|
|
||||||
myScriptEngine.m_logger.Verbose("ScriptEngine", "Invoke: \"" + Script.State + "_event_" + FunctionName + "\"");
|
m_scriptEngine.Log.Verbose("ScriptEngine", "Invoke: \"" + Script.State + "_event_" + FunctionName + "\"");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -254,7 +273,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
myScriptEngine.m_logger.Error("ScriptEngine", "Exception attempting to executing script function: " + e.ToString());
|
m_scriptEngine.Log.Error("ScriptEngine", "Exception attempting to executing script function: " + e.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -265,5 +284,12 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string RegionName
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return World.RegionInfo.RegionName;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue