Pimped up Default.lsl. Now featuring a touch counter.
Changed "ObjectID" in ScriptEngine to IScriptHost reference. Events will now be queued based on IScriptHost reference instead of string ID of object. Removed "root" object reference in script.afrisby
parent
577fb1a987
commit
fcf7db7272
|
@ -181,7 +181,7 @@ namespace OpenSim
|
|||
OpenSim.Region.Environment.Scenes.Scripting.ScriptEngineInterface ScriptEngine = ScriptEngineLoader.LoadScriptEngine("DotNetEngine");
|
||||
scene.AddScriptEngine(ScriptEngine, m_log);
|
||||
// TODO: TEMP load default script
|
||||
ScriptEngine.StartScript(Path.Combine("ScriptEngines", "Default.lsl"), "TEST");
|
||||
ScriptEngine.StartScript(Path.Combine("ScriptEngines", "Default.lsl"), new OpenSim.Region.Environment.Scenes.Scripting.NullScriptHost());
|
||||
|
||||
|
||||
m_localScenes.Add(scene);
|
||||
|
|
|
@ -18,6 +18,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
{
|
||||
private const uint FULL_MASK_PERMISSIONS = 2147483647;
|
||||
|
||||
|
||||
public LLUUID CreatorID;
|
||||
public LLUUID OwnerID;
|
||||
public LLUUID GroupID;
|
||||
|
|
|
@ -7,6 +7,7 @@ namespace OpenSim.Region.Environment.Scenes.Scripting
|
|||
{
|
||||
public class NullScriptHost : IScriptHost
|
||||
{
|
||||
|
||||
LLVector3 m_pos = new LLVector3( 128, 128, 30 );
|
||||
public string Name
|
||||
{
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenSim.Region.Environment.Scenes.Scripting;
|
||||
|
||||
//TODO: WHERE TO PLACE THIS?
|
||||
namespace OpenSim.Region.Environment.Scenes.Scripting
|
||||
{
|
||||
|
@ -36,6 +38,6 @@ namespace OpenSim.Region.Environment.Scenes.Scripting
|
|||
{
|
||||
void InitializeEngine(OpenSim.Region.Environment.Scenes.Scene Sceneworld, OpenSim.Framework.Console.LogBase logger);
|
||||
void Shutdown();
|
||||
void StartScript(string ScriptID, string ObjectID);
|
||||
void StartScript(string ScriptID, IScriptHost ObjectID);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -232,8 +232,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
|
|||
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";
|
||||
OpenSim.Region.Environment.Scenes.Scripting.IScriptHost host ) : base( manager, host ) { }"+"\r\n";
|
||||
Return += Script;
|
||||
Return += "} }\r\n";
|
||||
|
||||
|
|
|
@ -16,13 +16,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
|
|||
|
||||
protected ScriptManager m_manager;
|
||||
protected IScriptHost m_host;
|
||||
protected IScriptHost m_root;
|
||||
|
||||
public LSL_BaseClass(ScriptManager manager, IScriptHost host, IScriptHost root)
|
||||
public LSL_BaseClass(ScriptManager manager, IScriptHost host)
|
||||
{
|
||||
m_manager = manager;
|
||||
m_host = host;
|
||||
m_root = root;
|
||||
}
|
||||
|
||||
public Scene World
|
||||
|
|
|
@ -31,6 +31,7 @@ using System.Collections.Generic;
|
|||
using System.Text;
|
||||
using libsecondlife;
|
||||
using OpenSim.Framework.Interfaces;
|
||||
using OpenSim.Region.Environment.Scenes.Scripting;
|
||||
|
||||
namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
||||
{
|
||||
|
@ -40,6 +41,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
|||
class EventManager
|
||||
{
|
||||
private ScriptEngine myScriptEngine;
|
||||
public IScriptHost TEMP_OBJECT_ID;
|
||||
public EventManager(ScriptEngine _ScriptEngine)
|
||||
{
|
||||
myScriptEngine = _ScriptEngine;
|
||||
|
@ -58,7 +60,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
|||
{
|
||||
// Add to queue for all scripts in ObjectID object
|
||||
//myScriptEngine.m_logger.Verbose("ScriptEngine", "EventManager Event: touch_start");
|
||||
myScriptEngine.myEventQueueManager.AddToObjectQueue("TEST", "touch_start", new object[] { (int)0 });
|
||||
myScriptEngine.myEventQueueManager.AddToObjectQueue(TEMP_OBJECT_ID, "touch_start", new object[] { (int)0 });
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
@ -45,7 +46,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
|||
private Queue<QueueItemStruct> EventQueue = new Queue<QueueItemStruct>();
|
||||
private struct QueueItemStruct
|
||||
{
|
||||
public string ObjectID;
|
||||
public IScriptHost ObjectID;
|
||||
public string ScriptID;
|
||||
public string FunctionName;
|
||||
public object[] param;
|
||||
|
@ -109,7 +110,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
|||
}
|
||||
}
|
||||
|
||||
public void AddToObjectQueue(string ObjectID, string FunctionName, object[] param)
|
||||
public void AddToObjectQueue(IScriptHost ObjectID, string FunctionName, object[] param)
|
||||
{
|
||||
// Determine all scripts in Object and add to their queue
|
||||
//myScriptEngine.m_logger.Verbose("ScriptEngine", "EventQueueManager Adding ObjectID: " + ObjectID + ", FunctionName: " + FunctionName);
|
||||
|
|
|
@ -30,6 +30,8 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenSim.Framework.Console;
|
||||
//using OpenSim.Region.Environment.Scenes;
|
||||
using OpenSim.Region.Environment.Scenes.Scripting;
|
||||
|
||||
namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
||||
{
|
||||
|
@ -80,8 +82,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
|||
|
||||
// !!!FOR DEBUGGING ONLY!!! (for executing script directly from test app)
|
||||
[Obsolete("!!!FOR DEBUGGING ONLY!!!")]
|
||||
public void StartScript(string ScriptID, string ObjectID)
|
||||
public void StartScript(string ScriptID, IScriptHost ObjectID)
|
||||
{
|
||||
this.myEventManager.TEMP_OBJECT_ID = ObjectID;
|
||||
Log.Status("ScriptEngine", "DEBUG FUNCTION: StartScript: " + ScriptID);
|
||||
myScriptManager.StartScript(ScriptID, ObjectID);
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
|||
|
||||
|
||||
// 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<IScriptHost, Dictionary<string, OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass>> Scripts = new Dictionary<IScriptHost, Dictionary<string, OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass>>();
|
||||
public Scene World
|
||||
{
|
||||
get
|
||||
|
@ -63,7 +63,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
|||
}
|
||||
|
||||
|
||||
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(IScriptHost ObjectID)
|
||||
{
|
||||
if (Scripts.ContainsKey(ObjectID) == false)
|
||||
return null;
|
||||
|
@ -75,7 +75,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
|||
|
||||
}
|
||||
|
||||
internal OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass GetScript(string ObjectID, string ScriptID)
|
||||
internal OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass GetScript(IScriptHost ObjectID, string ScriptID)
|
||||
{
|
||||
if (Scripts.ContainsKey(ObjectID) == false)
|
||||
return null;
|
||||
|
@ -92,7 +92,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
|||
return Script;
|
||||
|
||||
}
|
||||
internal void SetScript(string ObjectID, string ScriptID, OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass Script)
|
||||
internal void SetScript(IScriptHost ObjectID, string ScriptID, OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass Script)
|
||||
{
|
||||
// Create object if it doesn't exist
|
||||
if (Scripts.ContainsKey(ObjectID) == false)
|
||||
|
@ -116,8 +116,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
|||
/// </summary>
|
||||
/// <param name="ScriptID"></param>
|
||||
/// <param name="ObjectID"></param>
|
||||
public void StartScript(string ScriptID, string ObjectID)
|
||||
public void StartScript(string ScriptID, IScriptHost ObjectID)
|
||||
{
|
||||
//IScriptHost root = host.GetRoot();
|
||||
m_scriptEngine.Log.Verbose("ScriptEngine", "ScriptManager StartScript: ScriptID: " + ScriptID + ", ObjectID: " + ObjectID);
|
||||
|
||||
// We will initialize and start the script.
|
||||
|
@ -162,11 +163,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
|||
// * Load and start script, for now with dummy host
|
||||
|
||||
//OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO.LSL_BaseClass Script = LoadAndInitAssembly(FreeAppDomain, FileName);
|
||||
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;
|
||||
OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass Script = LoadAndInitAssembly(FreeAppDomain, FileName, ObjectID);
|
||||
//string FullScriptID = ScriptID + "." + ObjectID;
|
||||
// Add it to our temporary active script keeper
|
||||
//Scripts.Add(FullScriptID, Script);
|
||||
SetScript(ObjectID, ScriptID, Script);
|
||||
|
@ -206,7 +205,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
|||
/// <param name="FreeAppDomain">AppDomain to load script into</param>
|
||||
/// <param name="FileName">FileName of script assembly (.dll)</param>
|
||||
/// <returns></returns>
|
||||
private OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass LoadAndInitAssembly(AppDomain FreeAppDomain, string FileName, IScriptHost host, IScriptHost root)
|
||||
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)
|
||||
|
@ -249,8 +248,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
|||
object[] args = new object[]
|
||||
{
|
||||
this,
|
||||
host,
|
||||
root
|
||||
host
|
||||
};
|
||||
|
||||
return (OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass)Activator.CreateInstance(t, args );
|
||||
|
@ -258,7 +256,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
|||
|
||||
}
|
||||
|
||||
internal void ExecuteFunction(string ObjectID, string ScriptID, string FunctionName, object[] args)
|
||||
internal void ExecuteFunction(IScriptHost ObjectID, string ScriptID, string FunctionName, object[] args)
|
||||
{
|
||||
m_scriptEngine.Log.Verbose("ScriptEngine", "Executing Function ObjectID: " + ObjectID + ", ScriptID: " + ScriptID + ", FunctionName: " + FunctionName);
|
||||
OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass Script = m_scriptEngine.myScriptManager.GetScript(ObjectID, ScriptID);
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
integer touch_count = 0;
|
||||
default {
|
||||
state_entry()
|
||||
{
|
||||
|
@ -6,6 +7,7 @@ default {
|
|||
|
||||
touch_start(integer total_number)
|
||||
{
|
||||
llSay(0, "Object was touched.");
|
||||
touch_count++;
|
||||
llSay(0, "Object was touched. Touch count: " + touch_count);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue