2

我试图使以下脚本仅在某个组中的用户可以传送到指定的 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()); 
  }
 }
}

想法?

4

2 回答 2

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之后从头开始写的,所以如果你发现错误,请告诉我。:-)

于 2009-09-01T20:46:42.317 回答
0

是的,某处似乎有错误。我很确定所有括号都已关闭,因此很可能在脚本正文中。我会继续寻找,如果我发现它,请告诉你。

于 2009-09-12T05:57:02.507 回答