SL传送多用户门?

时间:2009-09-01 16:22:52

标签: secondlife linden-scripting-language

我正在尝试使以下脚本仅在某个组中的用户可以传送到指定的x,y,z坐标时才有效。

来源:www.heatonresearch.com

// Scripting Recipes for Second Life
// by Jeff Heaton (Encog Dod in SL)
// ISBN: 160439000X
// Copyright 2007 by Heaton Research, Inc.
//
// This script may be freely copied and modified so long as this header
// remains unmodified.
//
// For more information about this book visit the following web site:
//
// http://www.heatonresearch.com/articles/series/22/

vector target=<190, 197, 64>;

vector offset;

default
{    
    moving_end()
    {
        offset = (target- llGetPos()) * (ZERO_ROTATION / llGetRot());
        llSitTarget(offset, ZERO_ROTATION); 
    }

    state_entry()
    {
        llSetText("Teleport pad",<0,0,0>,1.0);
        offset = (target- llGetPos()) * (ZERO_ROTATION / llGetRot());
        llSetSitText("Teleport");
        llSitTarget(offset, ZERO_ROTATION);      
    }

    changed(integer change) 
    { 
        if (change & CHANGED_LINK) 
        { 
            llSleep(0.5); 
            if (llAvatarOnSitTarget() != NULL_KEY) 
            { 
                llUnSit(llAvatarOnSitTarget()); 
            }
        }
    }

    touch_start(integer i)
    {
        llSay(0, "Please right-click and select Teleport");
    }
}
    The teleport script uses two global variables. They are.

vector target=<190, 197, 64>;
vector offset;    The target is the coordinate that the teleport script should send the user to. The offset is calculated based on the target and the current position of the teleporter. The offset is the distance that must be traveled to reach the target, starting from the teleporter.

    Whenever the teleport pad is moved, the offset must be recalculated. The sit target is then updated.

moving_end()
{
 offset = (target- llGetPos()) * 
  (ZERO_ROTATION / llGetRot());
 llSitTarget(offset, ZERO_ROTATION); 
}    Likewise, when the teleport pad is first created, the offset must be recalculated. Additionally, the sit text is specified. Rotation is also taken into account and neutralized. 

state_entry()
{
 llSetText("Teleport pad",<0,0,0>,1.0);
 offset = (target- llGetPos()) * 
  (ZERO_ROTATION / llGetRot());
 llSetSitText("Teleport");
 llSitTarget(offset, ZERO_ROTATION);      
}    When a user sits on the teleport pad, their avatar sits at the target location. The avatar is then stood up.

changed(integer change) 
{ 
 if (change & CHANGED_LINK) 
     { 
  llSleep(0.5); 
  if (llAvatarOnSitTarget() != NULL_KEY) 
  { 
   llUnSit(llAvatarOnSitTarget()); 
  }
 }
}

想法?

2 个答案:

答案 0 :(得分:1)

我还没有在SecondLife工作过一段时间,但最终目标是不是最大化到10米距离?人们不能轻易地使用坐姿目标来穿越墙壁并进入他们不应该进入的区域吗?执行此操作的最佳方法是不使用脚本(因为它们总是被绕过,甚至是用于区域安全性的推送脚本等),而是仅使用SecondLife的内置土地安全性。除了你的小组之外,根本不允许任何人访问该包裹。

如果真的希望按照自己的方式进行,那么您正在寻找的功能就是llSameGroup。只需确保为对象分配正确的组,然后llSameGroup(key id)将返回传递的id是否与对象在同一组中。

因为SecondLife在对象访问和捕获事件方面很多方面很糟糕,如果我没记错的话,你必须首先将坐标目标保持在错误的位置,然后只将其移动到正确的位置。用户坐在同一组中。否则,你可以做的最好的事情是让用户坐在上面,并且由于目标已经移动,当你的脚本将它们从你的传送器上移开时,它们已经被传送到你不希望它们去的地方。

更好的选择可能是制作一个不使用静止目标的远程传送器,但实际上将自己移动到目标位置所在的任何位置。这样,您可以使它不会移动,除非同一组中的某个人坐在其中。这样做非常简单。

vector targetPos = <100,100,100>;
vector originPos;

default
{
    state_entry()
    {
        originPos = llGetPos();
    }

    changed(integer type)
    {
        if(type & CHANGED_LINK && llGetAvatarOnSitTarget() != NULL_KEY)
        {
            llSetTimerEvent(0.1);
            llWhisper(0,"Going up!");
        }
    }

    timer()
    {
        key sitter = llAvatarOnSitTarget();

        //If someone is not sitting here, go back home.
        if (sitter == NULL_KEY)
        {
            llSetPos(originPos);

            //If we've reached the origin, stop the timer.
            if (llGetPos() == originPos)
            {
                llSetTimerEvent(0.0);
            }
        }
        //If someone is sitting here, go towards the teleport.
        else
        {
            //Before we move, make sure that they're in our group.
            if (llSameGroup(sitter))
            {
                llSetPos(targetPos);
            }
            else
            {
                llUnsit(sitter);
                llWhisper(0,"Get off me, man!");
            }

            //If we've reached the target, unsit the sitter.
            if (llGetPos() == targetPos)
            {
                llUnsit(sitter);
                llWhisper(0,"We've arrived!");
            }
        }
    }
}

我刚刚在没有玩SL超过几年后从头开始写了这个,所以如果你发现错误,请告诉我所有人。 : - )

答案 1 :(得分:0)

是的,某处似乎有错误。我很确定所有括号都是关闭的,所以它最有可能出现在脚本体内。我会继续寻找,如果我发现它,请告诉你。