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!
Another version... better :)
+ 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 :)
 
<pre>
NOTE: THIS IS JUST THE IDEA, THIS ISNT WORKING, IF YOU CAN FIX IT... POST HERE THE WORKING VERSION.. I'LL UPDATE IT SOON
</pre>


<lsl>
<lsl>
//  anti return created by Jor3l Boa
float TIMER_SIM_JUMP = 600.0;
//==================================================
//  (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:
safe_posJump( vector target_pos )
// - 0.2 automatic version
{
// - 0.1 initial release
    // An alternative to the warpPos trick without all the overhead.
integer sReg = FALSE;
    // Trickery discovered by Uchi Desmoulins and Gonta Maltz. More exact value provided by Fake Fitzgerald.  
vector to;
    // Safe movement modification provided by Alias Turbo.
vector myPos;
     vector start_pos = llGetPos();
doCheck(vector to)  {
     llSetPrimitiveParams( [ PRIM_POSITION , < 1.304382E+19 , 1.304382E+19 , 0.0 > , PRIM_POSITION , target_pos ,
    string status;
                            PRIM_POSITION , start_pos , PRIM_POSITION , target_pos ] );
    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 get_another_region()
     vector toP;
{
    vector this = llGetPos();
     list test = [ < 1.0 , 0.0 , 0.0 > , < -1.0 , 0.0 , 0.0 > , < 0.0 , 1.0 , 0.0 > , < 0.0 , -1.0 , 0.0 > ];
    if(a)  {
    integer i;
        if(to.x == 0)  this.x = dir.x;
    vector off;
        else    this.x = (this.x + dir.x + to.x);
    for ( ; i < 4 ; i += 1 )
        if(to.y == 0) this.y = dir.y;
    {
         else    this.y = (this.y + dir.y + to.y);
         off = llList2Vector( test , i );
         toP = <this.x,this.y,dir.z>;
         if ( !llEdgeOfWorld( < 128.0 , 128.0 , 100.0 > , off ) ) jump found;
     }
     }
     else    {
     return ZERO_VECTOR;
        if(to.x != 0) dir.x = to.x;
    @found;
        if(to.y != 0) dir.y = to.y;
    vector m_pos = llGetPos();
        toP = dir;
     return off * 254.0;
    }
     return toP;
}
 
warpPos(vector destpos)
{
  llSetPrimitiveParams([PRIM_POSITION, <1.304382E+19, 1.304382E+19, 0.0>, PRIM_POSITION,destpos]);
}
}


default
default
{
{
     state_entry()   {
     on_rez( integer start_param )
         llSetText("",<1,1,1>,1.0);
    {
        llSetColor(<1,0,0>,2);
         llResetScript();
     }
     }
     touch_start(integer total_number)
      
    state_entry()
     {
     {
        if(sReg) state noReturn;
         vector another_region = get_another_region();
        vector  myPos = llGetPos();
         if ( another_region )
        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>;
             llOwnerSay( "NR: Activated." );
         }
            llSetTimerEvent( TIMER_SIM_JUMP );
         else if(ang > 90+22.5 && ang < 135+22.5)
         } else llOwnerSay( "NR: This will not work in the current region." );
    }
 
    timer()
    {
        vector another_region = get_another_region();
         if ( another_region )
         {
         {
             to = <5,0,0>;
             safe_posJump( llGetPos() + another_region );
            llSleep( 2.0 );
            safe_posJump( llGetPos() - another_region );
         }
         }
        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>
</lsl>

Revision as of 12:00, 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

Another version... better :)

<lsl> float TIMER_SIM_JUMP = 600.0;

safe_posJump( vector target_pos ) {

   // An alternative to the warpPos trick without all the overhead.
   // Trickery discovered by Uchi Desmoulins and Gonta Maltz. More exact value provided by Fake Fitzgerald. 
   // Safe movement modification provided by Alias Turbo.
   vector start_pos = llGetPos();
   llSetPrimitiveParams( [ PRIM_POSITION , < 1.304382E+19 , 1.304382E+19 , 0.0 > , PRIM_POSITION , target_pos , 
                           PRIM_POSITION , start_pos , PRIM_POSITION , target_pos ] );

}

vector get_another_region() {

   list test = [ < 1.0 , 0.0 , 0.0 > , < -1.0 , 0.0 , 0.0 > , < 0.0 , 1.0 , 0.0 > , < 0.0 , -1.0 , 0.0 > ];
   integer i;
   vector off;
   for ( ; i < 4 ; i += 1 )
   {
       off = llList2Vector( test , i );
       if ( !llEdgeOfWorld( < 128.0 , 128.0 , 100.0 > , off ) ) jump found;
   }
   return ZERO_VECTOR;
   @found;
   vector m_pos = llGetPos();
   return off * 254.0;

}

default {

   on_rez( integer start_param )
   {
       llResetScript();
   }
   
   state_entry()
   {
       vector another_region = get_another_region();
       if ( another_region )
       {
           llOwnerSay( "NR: Activated." );
           llSetTimerEvent( TIMER_SIM_JUMP );
       } else llOwnerSay( "NR: This will not work in the current region." );
   }
   timer()
   {
       vector another_region = get_another_region();
       if ( another_region )
       {
           safe_posJump( llGetPos() + another_region );
           llSleep( 2.0 );
           safe_posJump( llGetPos() - another_region );
       }
   }

} </lsl>