Difference between revisions of "No Limit Teleporter"

From Second Life Wiki
Jump to navigation Jump to search
m (<lsl> tag to <source>)
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
'''Simple Teleporter - No Limitation'''
=Simple Teleporter - No Limitation=
----


Zero - Lag<br>
Zero - Lag<br>
Line 8: Line 7:
[+] Set dest (end of script) to the object destination.<br>
[+] Set dest (end of script) to the object destination.<br>


 
<syntaxhighlight lang="lsl2">
<source lang="lsl2">
//Leave that here
//Leave that here
//Script created by Morgam Biedermann
//Script created by Morgam Biedermann
Line 48: Line 46:
     }
     }
}
}
</source>
</syntaxhighlight>
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.<br>
 
<br>
== Critique to the above script by [[User:BETLOG Hax|BETLOG Hax]] ==
An equivalency check that respects SLs somewhat wiggly precision system, and isn't trying to match a movement to EXACTLY 6 decimal places of precision is needed.<br>
 
<source lang="lsl2">
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.
 
An equivalency check that respects SL's somewhat wiggly precision system, and isn't trying to match a movement to '''EXACTLY''' 6 decimal places of precision is needed.<br>
<syntaxhighlight lang="lsl2">
if(llGetPos() != dest)
if(llGetPos() != dest)
//is bad
//is bad
</source>
</syntaxhighlight>
<source lang="lsl2">
<syntaxhighlight lang="lsl2">
if(llVecDist(llGetPos(),dest)<0.001)
if(llVecDist(llGetPos(),dest)<0.001)
//is MUCH better
//is MUCH better
</source>
</syntaxhighlight>
ie:
ie:
<source lang="lsl2">
<syntaxhighlight lang="lsl2">
teleports(vector dest)
teleports(vector dest)
{
{
Line 67: Line 68:
// This an inherently bad approach; given 6 decimal places on 3 floats in a vector its  
// 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  
// very UNlikely the equivalency will be precisely equal even if its VERY close, this  
// will become especially evident at high altitude. It'll look like its stopped,  
// will become 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.
// but the llSetPos() will be still thrashing away. Possibly for quite some time/forever.
//
//
Line 76: Line 77:
     }
     }
}
}
</source>
</syntaxhighlight>
And a system that has a user function call itself from within itself is probably not good.
And a system that has a user function call itself from within itself is probably not good.
This is MUCH Better. [MUST be compiled in MONO]
This is '''MUCH''' better: ['''MUST''' be compiled in [[Mono|MONO]]]
<source lang="lsl2">
<syntaxhighlight lang="lsl2">
teleports(vector dest)
teleports(vector dest)
{  list l=[PRIM_POSITION,dest];
{  list l=[PRIM_POSITION,dest];
Line 85: Line 86:
     llSetPrimitiveParams(l);
     llSetPrimitiveParams(l);
}
}
</source>
</syntaxhighlight>
 
[[Category:LSL Examples]]

Latest revision as of 10:22, 24 September 2022

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.

//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>);
    }
}

Critique to the above script by BETLOG Hax

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.

An equivalency check that respects SL's somewhat wiggly precision system, and isn't trying to match a movement to EXACTLY 6 decimal places of precision is needed.

if(llGetPos() != dest)
//is bad
if(llVecDist(llGetPos(),dest)<0.001)
//is MUCH better

ie:

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 become 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.001)
    {   llSetPos(dest); //corrected variable
        teleports(dest); //corrected variable
    }
}

And a system that has a user function call itself from within itself is probably not good. This is MUCH better: [MUST be compiled in MONO]

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);
}