* 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.
This commit is contained in:
lbsa71
2007-04-03 19:12:07 +00:00
parent 6d8dcd1d1d
commit 7169acc47e
12 changed files with 276 additions and 155 deletions

View File

@@ -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( "<li>[{0}] \"{1}\" @ {2} <a href=\"{3}\">add test script</a></li>", entity.uuid, entity.getName(), entity.position, testScriptLink );
responseString += String.Format( "<li>[{0}] \"{1}\" @ {2} <a href=\"{3}\">add test script</a></li>", entity.uuid, entity.Name, entity.Pos, testScriptLink );
}
responseString += "</ul>";
return responseString;