aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/DotNetEngine
diff options
context:
space:
mode:
authorlbsa712007-08-16 17:08:03 +0000
committerlbsa712007-08-16 17:08:03 +0000
commit25fd8d02738e61e81f93ac784b02ab84697ee528 (patch)
treedb1dda71b3aa86770fa90ae84d4ac361a6fd84c7 /OpenSim/Region/ScriptEngine/DotNetEngine
parentDeleted old inventoryCache.cs (diff)
downloadopensim-SC_OLD-25fd8d02738e61e81f93ac784b02ab84697ee528.zip
opensim-SC_OLD-25fd8d02738e61e81f93ac784b02ab84697ee528.tar.gz
opensim-SC_OLD-25fd8d02738e61e81f93ac784b02ab84697ee528.tar.bz2
opensim-SC_OLD-25fd8d02738e61e81f93ac784b02ab84697ee528.tar.xz
* Introduced IScriptHost as an interface to fetching object data from scripts.
* This meant introducing AbsolutePosition on all objects (since SimChat wants that)
Diffstat (limited to 'OpenSim/Region/ScriptEngine/DotNetEngine')
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs1
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs23
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs15
3 files changed, 31 insertions, 8 deletions
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
229 // Add namespace, class name and inheritance 229 // Add namespace, class name and inheritance
230 Return = "namespace SecondLife {\r\n"; 230 Return = "namespace SecondLife {\r\n";
231 Return += "public class Script : OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass {\r\n"; 231 Return += "public class Script : OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass {\r\n";
232 Return += "public Script( OpenSim.Region.Environment.Scenes.Scripting.IScriptHost host ) : base( host ) { }\r\n";
232 Return += Script; 233 Return += Script;
233 Return += "} }\r\n"; 234 Return += "} }\r\n";
234 235
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;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Text; 3using System.Text;
4using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler; 4using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler;
5using libsecondlife;
6using OpenSim.Region.Environment.Scenes;
7using OpenSim.Region.Environment.Scenes.Scripting;
8using OpenSim.Framework.Console;
5 9
6namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL 10namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
7{ 11{
@@ -11,11 +15,17 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
11 internal OpenSim.Region.Environment.Scenes.Scene World; 15 internal OpenSim.Region.Environment.Scenes.Scene World;
12 private System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); 16 private System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
13 17
14 18 IScriptHost m_host;
19
20 public LSL_BaseClass( IScriptHost host )
21 {
22 m_host = host;
23 }
24
15 public void Start(OpenSim.Region.Environment.Scenes.Scene _World, string FullScriptID) 25 public void Start(OpenSim.Region.Environment.Scenes.Scene _World, string FullScriptID)
16 { 26 {
17 World = _World; 27 World = _World;
18 Console.WriteLine("ScriptEngine", "LSL_BaseClass.Start() called. FullScriptID: " + FullScriptID); 28 MainLog.Instance.Notice( "ScriptEngine", "LSL_BaseClass.Start() called. FullScriptID: " + FullScriptID + ": Hosted by [" + m_host.Name + ":" + m_host.UUID + "@"+m_host.AbsolutePosition +"]");
19 29
20 return; 30 return;
21 } 31 }
@@ -59,8 +69,14 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
59 //Common.SendToDebug("INTERNAL FUNCTION llSay(" + (int)channelID + ", \"" + (string)text + "\");"); 69 //Common.SendToDebug("INTERNAL FUNCTION llSay(" + (int)channelID + ", \"" + (string)text + "\");");
60 Console.WriteLine("llSay Channel " + channelID + ", Text: \"" + text + "\""); 70 Console.WriteLine("llSay Channel " + channelID + ", Text: \"" + text + "\"");
61 //type for say is 1 71 //type for say is 1
62 //World.SimChat(enc.GetBytes(text), 1, World.Objects[World.ConvertLocalIDToFullID(MY_OBJECT_ID)], MY_OBJECT_NAME, World.Objects[World.ConvertLocalIDToFullID(MY_OBJECT_ID)]); 72
73 LLVector3 fromPos = m_host.AbsolutePosition; // Position of parent
74 string fromName = m_host.Name; // Name of script parent
75 LLUUID fromUUID = m_host.UUID; // UUID of parent
76
77 World.SimChat( Helpers.StringToField( text ), 1, fromPos, fromName, fromUUID );
63 } 78 }
79
64 public void llShout(int channelID, string text) 80 public void llShout(int channelID, string text)
65 { 81 {
66 Console.WriteLine("llShout Channel " + channelID + ", Text: \"" + text + "\""); 82 Console.WriteLine("llShout Channel " + channelID + ", Text: \"" + text + "\"");
@@ -68,6 +84,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
68 //World.SimChat(enc.GetBytes(text), 2, World.Objects[World.ConvertLocalIDToFullID(MY_OBJECT_ID)], MY_OBJECT_NAME, World.Objects[World.ConvertLocalIDToFullID(MY_OBJECT_ID)]); 84 //World.SimChat(enc.GetBytes(text), 2, World.Objects[World.ConvertLocalIDToFullID(MY_OBJECT_ID)], MY_OBJECT_NAME, World.Objects[World.ConvertLocalIDToFullID(MY_OBJECT_ID)]);
69 85
70 } 86 }
87
71 public int llListen(int channelID, string name, string ID, string msg) { return 0; } 88 public int llListen(int channelID, string name, string ID, string msg) { return 0; }
72 public void llListenControl(int number, int active) { return; } 89 public void llListenControl(int number, int active) { return; }
73 public void llListenRemove(int number) { return; } 90 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;
31using System.Text; 31using System.Text;
32using System.Threading; 32using System.Threading;
33using System.Reflection; 33using System.Reflection;
34using OpenSim.Region.Environment.Scenes.Scripting;
34 35
35namespace OpenSim.Region.ScriptEngine.DotNetEngine 36namespace OpenSim.Region.ScriptEngine.DotNetEngine
36{ 37{
@@ -148,10 +149,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
148 // * Find next available AppDomain to put it in 149 // * Find next available AppDomain to put it in
149 AppDomain FreeAppDomain = GetFreeAppDomain(); 150 AppDomain FreeAppDomain = GetFreeAppDomain();
150 151
151 // * Load and start script 152 // * Load and start script, for now with dummy host
153
152 //OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO.LSL_BaseClass Script = LoadAndInitAssembly(FreeAppDomain, FileName); 154 //OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO.LSL_BaseClass Script = LoadAndInitAssembly(FreeAppDomain, FileName);
153 OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass Script = LoadAndInitAssembly(FreeAppDomain, FileName); 155 OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass Script = LoadAndInitAssembly(FreeAppDomain, FileName, new NullScriptHost() );
154 string FullScriptID = ScriptID + "." + ObjectID; 156 string FullScriptID = ScriptID + "." + ObjectID;
155 // Add it to our temporary active script keeper 157 // Add it to our temporary active script keeper
156 //Scripts.Add(FullScriptID, Script); 158 //Scripts.Add(FullScriptID, Script);
157 SetScript(ObjectID, ScriptID, Script); 159 SetScript(ObjectID, ScriptID, Script);
@@ -161,6 +163,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
161 163
162 // Start the script - giving it BuiltIns 164 // Start the script - giving it BuiltIns
163 //myScriptEngine.m_logger.Verbose("ScriptEngine", "ScriptManager initializing script, handing over private builtin command interface"); 165 //myScriptEngine.m_logger.Verbose("ScriptEngine", "ScriptManager initializing script, handing over private builtin command interface");
166
164 Script.Start(myScriptEngine.World, ScriptID); 167 Script.Start(myScriptEngine.World, ScriptID);
165 168
166 } 169 }
@@ -189,7 +192,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
189 /// <param name="FreeAppDomain">AppDomain to load script into</param> 192 /// <param name="FreeAppDomain">AppDomain to load script into</param>
190 /// <param name="FileName">FileName of script assembly (.dll)</param> 193 /// <param name="FileName">FileName of script assembly (.dll)</param>
191 /// <returns></returns> 194 /// <returns></returns>
192 private OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass LoadAndInitAssembly(AppDomain FreeAppDomain, string FileName) 195 private OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass LoadAndInitAssembly(AppDomain FreeAppDomain, string FileName, IScriptHost host)
193 { 196 {
194 //myScriptEngine.m_logger.Verbose("ScriptEngine", "ScriptManager Loading Assembly " + FileName); 197 //myScriptEngine.m_logger.Verbose("ScriptEngine", "ScriptManager Loading Assembly " + FileName);
195 // Load .Net Assembly (.dll) 198 // Load .Net Assembly (.dll)
@@ -228,7 +231,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
228 //{ 231 //{
229 //} 232 //}
230 233
231 return (OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass)Activator.CreateInstance(t); 234 object[] args = new object[] { host };
235
236 return (OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass)Activator.CreateInstance(t, args );
232 237
233 238
234 } 239 }