No Limit Teleporter: Difference between revisions
BETLOG Hax (talk | contribs) mNo edit summary |
BETLOG Hax (talk | contribs) mNo edit summary |
||
| Line 7: | Line 7: | ||
[+] Set stapos (end of script) to the object position (where to back when the destination is reach).<br> | [+] Set stapos (end of script) to the object position (where to back when the destination is reach).<br> | ||
[+] Set dest (end of script) to the object destination.<br> | [+] Set dest (end of script) to the object destination.<br> | ||
<lsl> | <lsl> | ||
| Line 47: | Line 47: | ||
teleport(<141,19,505>); | teleport(<141,19,505>); | ||
} | } | ||
}</lsl> | } | ||
</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.<br> | |||
<br> | |||
</ | 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> | ||
<lsl> | |||
if(llGetPos() != dest) | |||
//is bad<br> | |||
</lsl> | |||
<lsl> | |||
if(llVecDist(llGetPos(),dest)<0.001) | |||
//is MUCH better<br> | |||
</lsl> | |||
ie: | |||
<lsl> | <lsl> | ||
teleports(vector dest) | teleports(vector dest) | ||
| Line 63: | Line 71: | ||
// | // | ||
// the below will stop in a timely manner. | // the below will stop in a timely manner. | ||
if(llVecDist(llGetPos(),dest) <= 0. | if(llVecDist(llGetPos(),dest) <= 0.001) | ||
{ llSetPos(dest); //corrected variable | { llSetPos(dest); //corrected variable | ||
teleports(dest); //corrected variable | teleports(dest); //corrected variable | ||
| Line 69: | Line 77: | ||
} | } | ||
</lsl> | </lsl> | ||
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] | |||
MUCH Better. [MUST be compiled in MONO] | |||
<lsl> | <lsl> | ||
teleports(vector dest) | teleports(vector dest) | ||
Revision as of 12:01, 4 October 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.
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.
<lsl>
if(llGetPos() != dest)
//is bad
</lsl>
<lsl>
if(llVecDist(llGetPos(),dest)<0.001)
//is MUCH better
</lsl>
ie:
<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 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
}
} </lsl> 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] <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>