Difference between revisions of "No Auto-Return NR"

From Second Life Wiki
Jump to navigation Jump to search
Line 46: Line 46:
NOTE: I am not responsible for the use you give to this code, you are free to use it at your OWN risk
NOTE: I am not responsible for the use you give to this code, you are free to use it at your OWN risk


AUTOMATIC VERSION!
AUTOMATED VERSION!
+ Second version. This one needs an easy setup. (Should work for any region with neighbours...)
+ Second version. This one needs an easy setup. (Should work for any region with neighbours...)


Line 56: Line 56:


<lsl>
<lsl>
//  anti return created by Jor3l Boa
//==================================================
//  (works on blue and rausch combat region),
//  NOTE: for red, change -5 to 5 and + 5 to -5 :)
//  this anti return needs a nearby region
//  with entry perms to work.
//==================================================
// NOTE: USE IT AT YOUR OWN RISK! <------YOUR OWN RISK!
//version 0.2
//Change log:
//  - 0.2 automatic version
//  - 0.1 initial release
integer sReg = FALSE;
integer sReg = FALSE;
vector to;
vector to;

Revision as of 10:34, 30 May 2009

This script is released under DNSIOIWKU License, Free and Open for anyone...

<lsl> // anti return created by Jor3l Boa //================================================== // (works on blue and rausch combat region), // NOTE: for red, change -5 to 5 and + 5 to -5 :) // this anti return needs a nearby region // with entry perms to work. //================================================== // NOTE: USE IT AT YOUR OWN RISK! <------YOUR OWN RISK! //version 0.1

//Change log: // - 0.1 initial release

warpPos(vector destpos) {

  llSetPrimitiveParams([PRIM_POSITION, <1.304382E+19, 1.304382E+19, 0.0>, PRIM_POSITION,destpos]);

} integer time;

default {

   state_entry()
   {
       llSetTimerEvent(10);
   }
   timer()
   {
       llSetTimerEvent(0);
       llSetColor(<1,0,0>,ALL_SIDES);
       vector pos = llGetPos();
           warpPos(<-5,pos.y,pos.z>);
       vector tpos = llGetPos();
           warpPos(<tpos.x + pos.x + 5,pos.y,pos.z>);
       llSetColor(<1,1,0>,ALL_SIDES);
           llSetTimerEvent(60);
       time++;
       //llSetText((string)time+" minutes\nin this region.",<1,0,0>,1.0);
   }

} </lsl>

NOTE: I am not responsible for the use you give to this code, you are free to use it at your OWN risk

AUTOMATED VERSION! + Second version. This one needs an easy setup. (Should work for any region with neighbours...)

HOW TO:

  1. Create a Box and add this script.
  2. Rotate it (pointing) to the region you want. (Make sure the red face points to that region)
  3. Touch and see if the object detects a region and is able to move.
  4. Touch again to start the noReturn and wait :)

<lsl> integer sReg = FALSE; vector to; vector myPos; doCheck(vector to) {

   string status;
   integer region = FALSE;
   vector vPosObject = llGetPos();
   if (!llEdgeOfWorld( vPosObject, to )){
     region = TRUE;
   }
   if(region)    {
       status = "No Region found!\nTry another direction.";
       sReg = FALSE;
   }
   else    {
       status = "Redy to Start.\nTouch again.";
       sReg = TRUE;
   }
   llSetText(status,<1,1,1>,1);

}

vector toPos(vector dir, integer a) {

   vector toP;
   vector this = llGetPos();
   if(a)   {
       if(to.x == 0)  this.x = dir.x;
       else    this.x = (this.x + dir.x + 5);
       if(to.y == 0)  this.y = dir.y;
       else    this.y = (this.y + dir.y + 5);
       toP = <this.x,this.y,dir.z>;
   }
   else    {
       if(to.x != 0) dir.x = to.x;
       if(to.y != 0) dir.y = to.y;
       toP = dir;
   }
   return toP;

}

warpPos(vector destpos) {

  llSetPrimitiveParams([PRIM_POSITION, <1.304382E+19, 1.304382E+19, 0.0>, PRIM_POSITION,destpos]);

}

default {

   state_entry()   {
       llSetText("",<1,1,1>,1.0);
       llSetColor(<1,0,0>,2);
   }
   touch_start(integer total_number)
   {
       if(sReg) state noReturn;
       vector   myPos = llGetPos();
       rotation myRot = llRotBetween(llRot2Fwd(llGetRot()),<myPos.x,myPos.y,0>);
       vector   eul   = llRot2Euler(myRot)*RAD_TO_DEG;
       float    ang   = llRot2Angle(myRot)*RAD_TO_DEG;
                ang   = ((eul.z)*1)+0;
       if(ang < 0) ang+=360;
       to = ZERO_VECTOR;        
       if(ang > 0+22.5 && ang < 45+22.5)
       {
           to = <0,5,0>;
       }
       else if(ang > 90+22.5 && ang < 135+22.5)
       {
           to = <5,0,0>;
       }
       else if(ang > 180+22.5 && ang < 225+22.5)
       {
           to = <0,-5,0>;
       }
       else if(ang > 270+22.5 && ang < 315+22.5)
       {
          to = <-5,0,0>; 
       }
       if(to == ZERO_VECTOR)
           llSetText("ERROR: Bad direction.\nRotate me again.",<1,0,0>,1);
       else
           doCheck(to);
   }

} state noReturn {

   state_entry()   {
       myPos = llGetPos();
       //llOwnerSay(llList2CSV([toPos(myPos,FALSE),toPos(myPos,TRUE)]));
       llSetTimerEvent(10);
   }   
   timer() {
       llSetTimerEvent(0);
           llSetColor(<1,0,0>,ALL_SIDES);
       warpPos(toPos(myPos,FALSE));
       warpPos(toPos(myPos,TRUE));
           llSetColor(<1,1,0>,ALL_SIDES);
       llSetTimerEvent(60);
   }

} </lsl>