From 25fd8d02738e61e81f93ac784b02ab84697ee528 Mon Sep 17 00:00:00 2001
From: lbsa71
Date: Thu, 16 Aug 2007 17:08:03 +0000
Subject: * Introduced IScriptHost as an interface to fetching object data from
scripts. * This meant introducing AbsolutePosition on all objects (since
SimChat wants that)
---
.../DotNetEngine/Compiler/LSL/LSL2CSConverter.cs | 1 +
.../DotNetEngine/Compiler/LSL/LSL_BaseClass.cs | 23 +++++++++++++++++++---
.../ScriptEngine/DotNetEngine/ScriptManager.cs | 15 +++++++++-----
3 files changed, 31 insertions(+), 8 deletions(-)
(limited to 'OpenSim/Region/ScriptEngine/DotNetEngine')
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs
index 13e3f2e..eea2094 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs
@@ -229,6 +229,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
// Add namespace, class name and inheritance
Return = "namespace SecondLife {\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 += Script;
Return += "} }\r\n";
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs
index 062060f..565bfb7 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs
@@ -2,6 +2,10 @@ using System;
using System.Collections.Generic;
using System.Text;
using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler;
+using libsecondlife;
+using OpenSim.Region.Environment.Scenes;
+using OpenSim.Region.Environment.Scenes.Scripting;
+using OpenSim.Framework.Console;
namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
{
@@ -11,11 +15,17 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
internal OpenSim.Region.Environment.Scenes.Scene World;
private System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
-
+ IScriptHost m_host;
+
+ public LSL_BaseClass( IScriptHost host )
+ {
+ m_host = host;
+ }
+
public void Start(OpenSim.Region.Environment.Scenes.Scene _World, string FullScriptID)
{
World = _World;
- Console.WriteLine("ScriptEngine", "LSL_BaseClass.Start() called. FullScriptID: " + FullScriptID);
+ MainLog.Instance.Notice( "ScriptEngine", "LSL_BaseClass.Start() called. FullScriptID: " + FullScriptID + ": Hosted by [" + m_host.Name + ":" + m_host.UUID + "@"+m_host.AbsolutePosition +"]");
return;
}
@@ -59,8 +69,14 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
//Common.SendToDebug("INTERNAL FUNCTION llSay(" + (int)channelID + ", \"" + (string)text + "\");");
Console.WriteLine("llSay Channel " + channelID + ", Text: \"" + text + "\"");
//type for say is 1
- //World.SimChat(enc.GetBytes(text), 1, World.Objects[World.ConvertLocalIDToFullID(MY_OBJECT_ID)], MY_OBJECT_NAME, World.Objects[World.ConvertLocalIDToFullID(MY_OBJECT_ID)]);
+
+ LLVector3 fromPos = m_host.AbsolutePosition; // Position of parent
+ string fromName = m_host.Name; // Name of script parent
+ LLUUID fromUUID = m_host.UUID; // UUID of parent
+
+ World.SimChat( Helpers.StringToField( text ), 1, fromPos, fromName, fromUUID );
}
+
public void llShout(int channelID, string text)
{
Console.WriteLine("llShout Channel " + channelID + ", Text: \"" + text + "\"");
@@ -68,6 +84,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
//World.SimChat(enc.GetBytes(text), 2, World.Objects[World.ConvertLocalIDToFullID(MY_OBJECT_ID)], MY_OBJECT_NAME, World.Objects[World.ConvertLocalIDToFullID(MY_OBJECT_ID)]);
}
+
public int llListen(int channelID, string name, string ID, string msg) { return 0; }
public void llListenControl(int number, int active) { return; }
public void llListenRemove(int number) { return; }
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs
index 2de4e62..8b5e3e3 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs
@@ -31,6 +31,7 @@ using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Reflection;
+using OpenSim.Region.Environment.Scenes.Scripting;
namespace OpenSim.Region.ScriptEngine.DotNetEngine
{
@@ -148,10 +149,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
// * Find next available AppDomain to put it in
AppDomain FreeAppDomain = GetFreeAppDomain();
- // * Load and start script
+ // * 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.LSL.LSL_BaseClass Script = LoadAndInitAssembly(FreeAppDomain, FileName);
- string FullScriptID = ScriptID + "." + ObjectID;
+ OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass Script = LoadAndInitAssembly(FreeAppDomain, FileName, new NullScriptHost() );
+ string FullScriptID = ScriptID + "." + ObjectID;
// Add it to our temporary active script keeper
//Scripts.Add(FullScriptID, Script);
SetScript(ObjectID, ScriptID, Script);
@@ -161,6 +163,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
// Start the script - giving it BuiltIns
//myScriptEngine.m_logger.Verbose("ScriptEngine", "ScriptManager initializing script, handing over private builtin command interface");
+
Script.Start(myScriptEngine.World, ScriptID);
}
@@ -189,7 +192,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
/// AppDomain to load script into
/// FileName of script assembly (.dll)
///
- private OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass LoadAndInitAssembly(AppDomain FreeAppDomain, string FileName)
+ private OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass LoadAndInitAssembly(AppDomain FreeAppDomain, string FileName, IScriptHost host)
{
//myScriptEngine.m_logger.Verbose("ScriptEngine", "ScriptManager Loading Assembly " + FileName);
// Load .Net Assembly (.dll)
@@ -228,7 +231,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
//{
//}
- return (OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass)Activator.CreateInstance(t);
+ object[] args = new object[] { host };
+
+ return (OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass)Activator.CreateInstance(t, args );
}
--
cgit v1.1