aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/OpenSim.Region/Scenes/scripting
diff options
context:
space:
mode:
authorAdam Frisby2007-06-28 08:09:05 +0000
committerAdam Frisby2007-06-28 08:09:05 +0000
commit0c1a6c85cc678effc882dd5897d3357416807ba9 (patch)
tree6149f74c6a5a4d75bbeea3711a687dc6dcc66a6f /OpenSim/OpenSim.Region/Scenes/scripting
parentSome very Preliminary work on .net remoting for interregion comms. (diff)
downloadopensim-SC-0c1a6c85cc678effc882dd5897d3357416807ba9.zip
opensim-SC-0c1a6c85cc678effc882dd5897d3357416807ba9.tar.gz
opensim-SC-0c1a6c85cc678effc882dd5897d3357416807ba9.tar.bz2
opensim-SC-0c1a6c85cc678effc882dd5897d3357416807ba9.tar.xz
* Brand spankin' new scripting engine.
* Use "script load somefile.cs" for C# scripting. Will commit additional languages shortly. Scripts should implement the IScript interfaces to work correctly. * Someone port this over to NameSpaceChanges (built in Sugilite since sugilite is working)
Diffstat (limited to 'OpenSim/OpenSim.Region/Scenes/scripting')
-rw-r--r--OpenSim/OpenSim.Region/Scenes/scripting/CSharpScriptEngine.cs77
-rw-r--r--OpenSim/OpenSim.Region/Scenes/scripting/IScriptContext.cs40
-rw-r--r--OpenSim/OpenSim.Region/Scenes/scripting/IScriptEntity.cs46
-rw-r--r--OpenSim/OpenSim.Region/Scenes/scripting/IScriptHandler.cs126
-rw-r--r--OpenSim/OpenSim.Region/Scenes/scripting/Script.cs71
-rw-r--r--OpenSim/OpenSim.Region/Scenes/scripting/ScriptFactory.cs35
-rw-r--r--OpenSim/OpenSim.Region/Scenes/scripting/ScriptInfo.cs31
-rw-r--r--OpenSim/OpenSim.Region/Scenes/scripting/ScriptManager.cs66
-rw-r--r--OpenSim/OpenSim.Region/Scenes/scripting/Scripts/FollowRandomAvatar.cs64
9 files changed, 205 insertions, 351 deletions
diff --git a/OpenSim/OpenSim.Region/Scenes/scripting/CSharpScriptEngine.cs b/OpenSim/OpenSim.Region/Scenes/scripting/CSharpScriptEngine.cs
new file mode 100644
index 0000000..d5622b8
--- /dev/null
+++ b/OpenSim/OpenSim.Region/Scenes/scripting/CSharpScriptEngine.cs
@@ -0,0 +1,77 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5// Compilation stuff
6using System.CodeDom;
7using System.CodeDom.Compiler;
8using Microsoft.CSharp;
9
10namespace OpenSim.Scripting
11{
12 public class CSharpScriptEngine : IScriptCompiler
13 {
14 public string fileExt()
15 {
16 return ".cs";
17 }
18
19 private Dictionary<string,IScript> LoadDotNetScript(ICodeCompiler compiler, string filename)
20 {
21 CompilerParameters compilerParams = new CompilerParameters();
22 CompilerResults compilerResults;
23 compilerParams.GenerateExecutable = false;
24 compilerParams.GenerateInMemory = true;
25 compilerParams.IncludeDebugInformation = false;
26 compilerParams.ReferencedAssemblies.Add("OpenSim.Region.dll");
27 compilerParams.ReferencedAssemblies.Add("OpenSim.Framework.dll");
28 compilerParams.ReferencedAssemblies.Add("libsecondlife.dll");
29 compilerParams.ReferencedAssemblies.Add("System.dll");
30
31 compilerResults = compiler.CompileAssemblyFromFile(compilerParams, filename);
32
33 if (compilerResults.Errors.Count > 0)
34 {
35 OpenSim.Framework.Console.MainLog.Instance.Error("Compile errors");
36 foreach (CompilerError error in compilerResults.Errors)
37 {
38 OpenSim.Framework.Console.MainLog.Instance.Error(error.Line.ToString() + ": " + error.ErrorText.ToString());
39 }
40 }
41 else
42 {
43 Dictionary<string,IScript> scripts = new Dictionary<string,IScript>();
44
45 foreach (Type pluginType in compilerResults.CompiledAssembly.GetExportedTypes())
46 {
47 Type testInterface = pluginType.GetInterface("IScript", true);
48
49 if (testInterface != null)
50 {
51 IScript script = (IScript)compilerResults.CompiledAssembly.CreateInstance(pluginType.ToString());
52
53 string scriptName = "C#/" + script.getName();
54 Console.WriteLine("Script: " + scriptName + " loaded.");
55
56 if (!scripts.ContainsKey(scriptName))
57 {
58 scripts.Add(scriptName, script);
59 }
60 else
61 {
62 scripts[scriptName] = script;
63 }
64 }
65 }
66 return scripts;
67 }
68 return null;
69 }
70
71 public Dictionary<string,IScript> compile(string filename)
72 {
73 CSharpCodeProvider csharpProvider = new CSharpCodeProvider();
74 return LoadDotNetScript(csharpProvider.CreateCompiler(), filename);
75 }
76 }
77}
diff --git a/OpenSim/OpenSim.Region/Scenes/scripting/IScriptContext.cs b/OpenSim/OpenSim.Region/Scenes/scripting/IScriptContext.cs
deleted file mode 100644
index daa1b92..0000000
--- a/OpenSim/OpenSim.Region/Scenes/scripting/IScriptContext.cs
+++ /dev/null
@@ -1,40 +0,0 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Text;
31using libsecondlife;
32
33namespace OpenSim.Region.Scripting
34{
35 public interface IScriptContext
36 {
37 IScriptEntity Entity { get; }
38 bool TryGetRandomAvatar(out IScriptReadonlyEntity avatar);
39 }
40}
diff --git a/OpenSim/OpenSim.Region/Scenes/scripting/IScriptEntity.cs b/OpenSim/OpenSim.Region/Scenes/scripting/IScriptEntity.cs
deleted file mode 100644
index 44b886f..0000000
--- a/OpenSim/OpenSim.Region/Scenes/scripting/IScriptEntity.cs
+++ /dev/null
@@ -1,46 +0,0 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Text;
31using libsecondlife;
32
33namespace OpenSim.Region.Scripting
34{
35 public interface IScriptReadonlyEntity
36 {
37 LLVector3 Pos { get; }
38 string Name { get; }
39 }
40
41 public interface IScriptEntity
42 {
43 LLVector3 Pos { get; set; }
44 string Name { get; }
45 }
46}
diff --git a/OpenSim/OpenSim.Region/Scenes/scripting/IScriptHandler.cs b/OpenSim/OpenSim.Region/Scenes/scripting/IScriptHandler.cs
deleted file mode 100644
index 797998d..0000000
--- a/OpenSim/OpenSim.Region/Scenes/scripting/IScriptHandler.cs
+++ /dev/null
@@ -1,126 +0,0 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Text;
31using libsecondlife;
32using OpenSim.Physics.Manager;
33using OpenSim.Region;
34using OpenSim.Region.Scenes;
35using Avatar=OpenSim.Region.Scenes.ScenePresence;
36using Primitive = OpenSim.Region.Scenes.Primitive;
37
38namespace OpenSim.Region.Scripting
39{
40 public delegate void ScriptEventHandler(IScriptContext context);
41
42 public class ScriptHandler : IScriptContext, IScriptEntity, IScriptReadonlyEntity
43 {
44 private Scene m_world;
45 private Script m_script;
46 private Entity m_entity;
47
48 public LLUUID ScriptId
49 {
50 get
51 {
52 return m_script.ScriptId;
53 }
54 }
55
56 public void OnFrame()
57 {
58 m_script.OnFrame(this);
59 }
60
61 public ScriptHandler(Script script, Entity entity, Scene world)
62 {
63 m_script = script;
64 m_entity = entity;
65 m_world = world;
66 }
67
68 #region IScriptContext Members
69
70 IScriptEntity IScriptContext.Entity
71 {
72 get
73 {
74 return this;
75 }
76 }
77
78 bool IScriptContext.TryGetRandomAvatar(out IScriptReadonlyEntity avatar)
79 {
80 foreach (Entity entity in m_world.Entities.Values )
81 {
82 if( entity is Avatar )
83 {
84 avatar = entity;
85 return true;
86 }
87 }
88
89 avatar = null;
90 return false;
91 }
92
93 #endregion
94
95 #region IScriptEntity and IScriptReadonlyEntity Members
96
97 public string Name
98 {
99 get
100 {
101 return m_entity.Name;
102 }
103 }
104
105 public LLVector3 Pos
106 {
107 get
108 {
109 return m_entity.Pos;
110 }
111
112 set
113 {
114 if (m_entity is Primitive)
115 {
116 Primitive prim = m_entity as Primitive;
117 // Of course, we really should have asked the physEngine if this is possible, and if not, returned false.
118 // prim.UpdatePosition( value );
119 }
120 }
121 }
122
123 #endregion
124 }
125
126}
diff --git a/OpenSim/OpenSim.Region/Scenes/scripting/Script.cs b/OpenSim/OpenSim.Region/Scenes/scripting/Script.cs
index 1d01f3c..57390bc 100644
--- a/OpenSim/OpenSim.Region/Scenes/scripting/Script.cs
+++ b/OpenSim/OpenSim.Region/Scenes/scripting/Script.cs
@@ -1,53 +1,44 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System; 1using System;
29using System.Collections.Generic; 2using System.Collections.Generic;
30using System.Text; 3using System.Text;
31using libsecondlife;
32 4
33namespace OpenSim.Region.Scripting 5using OpenSim.Framework.Console;
6using OpenSim.Framework;
7using OpenSim.Region;
8using OpenSim.Region.Scenes;
9
10namespace OpenSim.Scripting
34{ 11{
35 public class Script 12 public interface IScript
13 {
14 void Initialise(ScriptInfo scriptInfo);
15 string getName();
16 }
17
18 public class TestScript : IScript
36 { 19 {
37 private LLUUID m_scriptId; 20 ScriptInfo script;
38 public virtual LLUUID ScriptId 21
22 public string getName()
23 {
24 return "TestScript 0.1";
25 }
26
27 public void Initialise(ScriptInfo scriptInfo)
28 {
29 script = scriptInfo;
30 script.events.OnFrame += new OpenSim.Region.Scenes.EventManager.OnFrameDelegate(events_OnFrame);
31 script.events.OnNewPresence += new EventManager.OnNewPresenceDelegate(events_OnNewPresence);
32 }
33
34 void events_OnNewPresence(ScenePresence presence)
39 { 35 {
40 get 36 script.logger.Verbose("Hello " + presence.firstname.ToString() + "!");
41 {
42 return m_scriptId;
43 }
44 } 37 }
45 38
46 public Script( LLUUID scriptId ) 39 void events_OnFrame()
47 { 40 {
48 m_scriptId = scriptId; 41 //script.logger.Verbose("Hello World!");
49 } 42 }
50
51 public ScriptEventHandler OnFrame;
52 } 43 }
53} 44}
diff --git a/OpenSim/OpenSim.Region/Scenes/scripting/ScriptFactory.cs b/OpenSim/OpenSim.Region/Scenes/scripting/ScriptFactory.cs
deleted file mode 100644
index 32ef046..0000000
--- a/OpenSim/OpenSim.Region/Scenes/scripting/ScriptFactory.cs
+++ /dev/null
@@ -1,35 +0,0 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Text;
31
32namespace OpenSim.Region.Scripting
33{
34 public delegate Script ScriptFactory();
35}
diff --git a/OpenSim/OpenSim.Region/Scenes/scripting/ScriptInfo.cs b/OpenSim/OpenSim.Region/Scenes/scripting/ScriptInfo.cs
new file mode 100644
index 0000000..a9fede5
--- /dev/null
+++ b/OpenSim/OpenSim.Region/Scenes/scripting/ScriptInfo.cs
@@ -0,0 +1,31 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5using OpenSim.Region.Scenes;
6using OpenSim.Framework.Console;
7
8namespace OpenSim.Scripting
9{
10 /// <summary>
11 /// Class which provides access to the world
12 /// </summary>
13 public class ScriptInfo
14 {
15 // Reference to world.eventsManager provided for convenience
16 public EventManager events;
17
18 // The main world
19 public Scene world;
20
21 // The console
22 public LogBase logger;
23
24 public ScriptInfo(Scene scene)
25 {
26 world = scene;
27 events = world.eventManager;
28 logger = OpenSim.Framework.Console.MainLog.Instance;
29 }
30 }
31}
diff --git a/OpenSim/OpenSim.Region/Scenes/scripting/ScriptManager.cs b/OpenSim/OpenSim.Region/Scenes/scripting/ScriptManager.cs
new file mode 100644
index 0000000..ff5c115
--- /dev/null
+++ b/OpenSim/OpenSim.Region/Scenes/scripting/ScriptManager.cs
@@ -0,0 +1,66 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.Scripting
6{
7 public class ScriptManager
8 {
9 List<IScript> scripts = new List<IScript>();
10 OpenSim.Region.Scenes.Scene scene;
11 Dictionary<string, IScriptCompiler> compilers = new Dictionary<string, IScriptCompiler>();
12
13 private void LoadFromCompiler(Dictionary<string, IScript> compiledscripts)
14 {
15 foreach (KeyValuePair<string, IScript> script in compiledscripts)
16 {
17 ScriptInfo scriptInfo = new ScriptInfo(scene); // Since each script could potentially corrupt their access with a stray assignment, making a new one for each script.
18 OpenSim.Framework.Console.MainLog.Instance.Verbose("Loading " + script.Key);
19 script.Value.Initialise(scriptInfo);
20 scripts.Add(script.Value);
21 }
22 OpenSim.Framework.Console.MainLog.Instance.Verbose("Finished loading " + compiledscripts.Count.ToString() + " script(s)");
23 }
24
25 public ScriptManager(OpenSim.Region.Scenes.Scene world)
26 {
27 scene = world;
28
29 // Defualt Engines
30 CSharpScriptEngine csharpCompiler = new CSharpScriptEngine();
31 compilers.Add(csharpCompiler.fileExt(),csharpCompiler);
32 }
33
34 public void Compile(string filename)
35 {
36 foreach (KeyValuePair<string, IScriptCompiler> compiler in compilers)
37 {
38 if (filename.EndsWith(compiler.Key))
39 {
40 LoadFromCompiler(compiler.Value.compile(filename));
41 break;
42 }
43 }
44 }
45
46 public void RunScriptCmd(string[] args)
47 {
48 switch (args[0])
49 {
50 case "load":
51 Compile(args[1]);
52 break;
53
54 default:
55 OpenSim.Framework.Console.MainLog.Instance.Error("Unknown script command");
56 break;
57 }
58 }
59 }
60
61 interface IScriptCompiler
62 {
63 Dictionary<string,IScript> compile(string filename);
64 string fileExt();
65 }
66}
diff --git a/OpenSim/OpenSim.Region/Scenes/scripting/Scripts/FollowRandomAvatar.cs b/OpenSim/OpenSim.Region/Scenes/scripting/Scripts/FollowRandomAvatar.cs
deleted file mode 100644
index 21f07a8..0000000
--- a/OpenSim/OpenSim.Region/Scenes/scripting/Scripts/FollowRandomAvatar.cs
+++ /dev/null
@@ -1,64 +0,0 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Text;
31using libsecondlife;
32
33namespace OpenSim.Region.Scripting
34{
35 public class FollowRandomAvatar : Script
36 {
37 public FollowRandomAvatar()
38 : base(LLUUID.Random())
39 {
40 OnFrame += MyOnFrame;
41 }
42
43 private void MyOnFrame(IScriptContext context)
44 {
45 LLVector3 pos = context.Entity.Pos;
46
47 IScriptReadonlyEntity avatar;
48
49 if (context.TryGetRandomAvatar(out avatar))
50 {
51 LLVector3 avatarPos = avatar.Pos;
52
53 float x = pos.X + ((float)avatarPos.X.CompareTo(pos.X)) / 2;
54 float y = pos.Y + ((float)avatarPos.Y.CompareTo(pos.Y)) / 2;
55
56 LLVector3 newPos = new LLVector3(x, y, pos.Z);
57
58 context.Entity.Pos = newPos;
59 }
60 }
61 }
62
63
64}