From 7169acc47e8bb56581bd28c3bd921ca9236ba3c3 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Tue, 3 Apr 2007 19:12:07 +0000 Subject: * Extended Script API with GetRandomAvatar * The script will now get a IScriptEntity to it's host object with get/sets * The script gets a IScriptReadnlyEntity interface to entities other than the host object. * the test script now follows a random avatar. --- OpenSim.RegionServer/CAPS/AdminWebFront.cs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'OpenSim.RegionServer/CAPS') diff --git a/OpenSim.RegionServer/CAPS/AdminWebFront.cs b/OpenSim.RegionServer/CAPS/AdminWebFront.cs index 43996d0..0d03a57 100644 --- a/OpenSim.RegionServer/CAPS/AdminWebFront.cs +++ b/OpenSim.RegionServer/CAPS/AdminWebFront.cs @@ -9,6 +9,7 @@ using OpenSim.Assets; using OpenSim.Framework.Inventory; using libsecondlife; using OpenSim.RegionServer.world.scripting; +using Avatar=libsecondlife.Avatar; namespace OpenSim.CAPS { @@ -141,8 +142,6 @@ namespace OpenSim.CAPS private class TestScript : Script { - int toggle = 0; - public TestScript() : base(LLUUID.Random()) { @@ -151,13 +150,21 @@ namespace OpenSim.CAPS private void MyOnFrame(IScriptContext context) { - toggle = 2 - toggle; + LLVector3 pos = context.Entity.Pos; - LLVector3 pos = context.GetPos(); + IScriptReadonlyEntity avatar; + + if( context.TryGetRandomAvatar( out avatar ) ) + { + LLVector3 avatarPos = avatar.Pos; - pos.X += (toggle - 1); + float x = pos.X + ((float)avatarPos.X.CompareTo(pos.X))/2; + float y = pos.Y + ((float)avatarPos.Y.CompareTo(pos.Y))/2; - context.MoveTo(pos); + LLVector3 newPos = new LLVector3( x, y, pos.Z ); + + context.Entity.Pos = newPos; + } } } @@ -194,7 +201,7 @@ namespace OpenSim.CAPS foreach (Entity entity in m_world.Entities.Values) { string testScriptLink = "javascript:loadXMLDoc('Admin/AddTestScript/" + entity.uuid.ToString() + "');"; - responseString += String.Format( "