aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim.RegionServer/world/scripting/Scripts/FollowRandomAvatar.cs
diff options
context:
space:
mode:
authorlbsa712007-04-03 20:08:30 +0000
committerlbsa712007-04-03 20:08:30 +0000
commitf12ceff6925236ca184c5a7a9c010b5e4bdb1b70 (patch)
tree9c83230be4bbdc19501e854df63084399cd742ba /OpenSim.RegionServer/world/scripting/Scripts/FollowRandomAvatar.cs
parent* Extended Script API with GetRandomAvatar (diff)
downloadopensim-SC_OLD-f12ceff6925236ca184c5a7a9c010b5e4bdb1b70.zip
opensim-SC_OLD-f12ceff6925236ca184c5a7a9c010b5e4bdb1b70.tar.gz
opensim-SC_OLD-f12ceff6925236ca184c5a7a9c010b5e4bdb1b70.tar.bz2
opensim-SC_OLD-f12ceff6925236ca184c5a7a9c010b5e4bdb1b70.tar.xz
* The world can not contain ScriptFactories that creates unique instances of scripts for entities.
* Created Scripts folder to house trusted Scripts * The test script now lives in Scripts/FollowRandomAvatar.cs
Diffstat (limited to 'OpenSim.RegionServer/world/scripting/Scripts/FollowRandomAvatar.cs')
-rw-r--r--OpenSim.RegionServer/world/scripting/Scripts/FollowRandomAvatar.cs37
1 files changed, 37 insertions, 0 deletions
diff --git a/OpenSim.RegionServer/world/scripting/Scripts/FollowRandomAvatar.cs b/OpenSim.RegionServer/world/scripting/Scripts/FollowRandomAvatar.cs
new file mode 100644
index 0000000..388a95c
--- /dev/null
+++ b/OpenSim.RegionServer/world/scripting/Scripts/FollowRandomAvatar.cs
@@ -0,0 +1,37 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using libsecondlife;
5
6namespace OpenSim.RegionServer.world.scripting.Scripts
7{
8 public class FollowRandomAvatar : Script
9 {
10 public FollowRandomAvatar()
11 : base(LLUUID.Random())
12 {
13 OnFrame += MyOnFrame;
14 }
15
16 private void MyOnFrame(IScriptContext context)
17 {
18 LLVector3 pos = context.Entity.Pos;
19
20 IScriptReadonlyEntity avatar;
21
22 if (context.TryGetRandomAvatar(out avatar))
23 {
24 LLVector3 avatarPos = avatar.Pos;
25
26 float x = pos.X + ((float)avatarPos.X.CompareTo(pos.X)) / 2;
27 float y = pos.Y + ((float)avatarPos.Y.CompareTo(pos.Y)) / 2;
28
29 LLVector3 newPos = new LLVector3(x, y, pos.Z);
30
31 context.Entity.Pos = newPos;
32 }
33 }
34 }
35
36
37}