From f12ceff6925236ca184c5a7a9c010b5e4bdb1b70 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Tue, 3 Apr 2007 20:08:30 +0000 Subject: * 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 --- .../world/scripting/Scripts/FollowRandomAvatar.cs | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 OpenSim.RegionServer/world/scripting/Scripts/FollowRandomAvatar.cs (limited to 'OpenSim.RegionServer/world/scripting/Scripts') 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 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; + +namespace OpenSim.RegionServer.world.scripting.Scripts +{ + public class FollowRandomAvatar : Script + { + public FollowRandomAvatar() + : base(LLUUID.Random()) + { + OnFrame += MyOnFrame; + } + + private void MyOnFrame(IScriptContext context) + { + LLVector3 pos = context.Entity.Pos; + + IScriptReadonlyEntity avatar; + + if (context.TryGetRandomAvatar(out avatar)) + { + LLVector3 avatarPos = avatar.Pos; + + float x = pos.X + ((float)avatarPos.X.CompareTo(pos.X)) / 2; + float y = pos.Y + ((float)avatarPos.Y.CompareTo(pos.Y)) / 2; + + LLVector3 newPos = new LLVector3(x, y, pos.Z); + + context.Entity.Pos = newPos; + } + } + } + + +} -- cgit v1.1