Difference between revisions of "No Limit Teleporter"

From Second Life Wiki
Jump to navigation Jump to search
(New page: '''Simple Teleporter - No Limitation''' ---- Zero - Lag<br> You can do anything, change the code and all more... To use:<br> [+] Set stapos (end of script) to the object position (where t...)
 
Line 48: Line 48:
     }
     }
}</lsl>
}</lsl>
<b>
The above example is a really bad approach to use for many reasons. Not least of which is that lag is precisely what it *will* generate.
A much more efficient solution involves using warpPos or similar solutions instead of self referential functions with llSetPos() loops.
</b>
Bad, but less evil.
<lsl>
teleports(vector dest)
{
//    if(llGetPos() != stapos)
// This an inherently bad approach; given 6 decimal places on 3 floats in a vector its
// very UNlikely the equivalency will be precisely equal even if its VERY close, this
// will be come especially evident at high altitude. It'll look  like its stopped,
// but the llSetPos() will be still thrashing away. Possibly for quite some time/forever.
//
// the below will stop in a timely manner.
    if(llVecDist(llGetPos(),dest) <= 0.01)
    {  llSetPos(dest); //corrected variable
        teleports(dest); //corrected variable
    }
}
</lsl>
<br>
<br>
MUCH Better. [MUST be compiled in MONO]
<lsl>
teleports(vector dest)
{  list l=[PRIM_POSITION,dest];
    l+=l;l+=l;l+=l;l+=l;l+=l;l+=l;l+=l;l+=l;l+=l;
    llSetPrimitiveParams(l);
}
</lsl>

Revision as of 14:53, 28 May 2009

Simple Teleporter - No Limitation


Zero - Lag
You can do anything, change the code and all more... To use:
[+] Set stapos (end of script) to the object position (where to back when the destination is reach).
[+] Set dest (end of script) to the object destination.

)

<lsl> //Leave that here //Script created by Morgam Biedermann vector posnow; vector stapos; rotation rotnow; teleport(vector dest) {

   if(llGetPos() != dest)
   {
       llSetPos(dest);
       teleport(dest);
   }
   else
   {
       llUnSit(llAvatarOnSitTarget());
       teleports(stapos);
   }

} teleports(vector dest) {

   if(llGetPos() != stapos)
   {
       llSetPos(stapos);
       teleports(stapos);
   }

} default {

   state_entry()
   {
       stapos = <141,19,30>;
   }
   touch_start(integer vez)
   {
       if(llDetectedKey(0) == llGetOwner())
       teleport(<141,19,505>);
   }

}</lsl>

The above example is a really bad approach to use for many reasons. Not least of which is that lag is precisely what it *will* generate.
A much more efficient solution involves using warpPos or similar solutions instead of self referential functions with llSetPos() loops.

Bad, but less evil. <lsl> teleports(vector dest) { // if(llGetPos() != stapos) // This an inherently bad approach; given 6 decimal places on 3 floats in a vector its // very UNlikely the equivalency will be precisely equal even if its VERY close, this // will be come especially evident at high altitude. It'll look like its stopped, // but the llSetPos() will be still thrashing away. Possibly for quite some time/forever. // // the below will stop in a timely manner.

   if(llVecDist(llGetPos(),dest) <= 0.01)
   {   llSetPos(dest); //corrected variable
       teleports(dest); //corrected variable
   }

} </lsl>

MUCH Better. [MUST be compiled in MONO] <lsl> teleports(vector dest) { list l=[PRIM_POSITION,dest];

   l+=l;l+=l;l+=l;l+=l;l+=l;l+=l;l+=l;l+=l;l+=l;
   llSetPrimitiveParams(l);

} </lsl>