Difference between revisions of "Talk:WarpPos"

From Second Life Wiki
Jump to navigation Jump to search
m (Move the See Also out of the middle (where it landed after chat growth) to near the top)
(→‎Undocumented?: Commenting that llSetRegionPos() is available)
 
(12 intermediate revisions by 6 users not shown)
Line 2: Line 2:


Is this going to be changed in the future? [[User:TxMasterG Ping|TxMasterG Ping]] 18:50, 30 March 2007 (PDT)
Is this going to be changed in the future? [[User:TxMasterG Ping|TxMasterG Ping]] 18:50, 30 March 2007 (PDT)
The new function [[llSetRegionPos]](vector position) is intended to replace WarpPos.
: Note: this new function is already available in SL, thus rendering WarpPos technically obsolete — [[User:Gwyneth Llewelyn|Gwyneth Llewelyn]] ([[User talk:Gwyneth Llewelyn|talk]]) 13:11, 3 October 2022 (PDT)


== See Also ==
== See Also ==
Line 15: Line 19:
I do now see "Script run-time error": "Stack-Heap Collision" when I try to jump too far, for example:
I do now see "Script run-time error": "Stack-Heap Collision" when I try to jump too far, for example:


<lsl>
<syntaxhighlight lang="lsl2">
default
default
{
{
Line 27: Line 31:
     }
     }
}
}
</lsl>
</syntaxhighlight>


My Server: Second Life Server 1.24.10.106829
My Server: Second Life Server 1.24.10.106829
Line 51: Line 55:
Here's a variation that works better at my desk:
Here's a variation that works better at my desk:


<lsl>
<syntaxhighlight lang="lsl2">
list lwCopies(list copy, integer count)
list wwCopies(list copy, integer count)
{
{
     if(count <= 0)
     if(count <= 0)
Line 71: Line 75:
}
}


lwSetCloserPos(vector there)
wwSetCloserPos(vector there)
{
{
     list command = [PRIM_POSITION, there];
     list command = [PRIM_POSITION, there];
     float distance = llVecDist(llGetPos(), there);
     float distance = llVecDist(llGetPos(), there);
     if(1000.0 < distance) { distance = 1000.0; } // Script run-time error/ Stack-Heap Collision if too far away
     if(1000.0 < distance) { distance = 1000.0; } // Script run-time error/ Stack-Heap Collision if too far away
     llSetPrimitiveParams(lwCopies(command, 1 + (integer)(distance / 10.0)));
     llSetPrimitiveParams(wwCopies(command, 1 + (integer)(distance / 10.0)));
}  
}  


lwSetFarPos(vector there)
wwSetFarPos(vector there)
{
{
     float distance = llVecDist(llGetPos(), there);
     float distance = llVecDist(llGetPos(), there);
Line 85: Line 89:
     while(tries--)
     while(tries--)
     {
     {
         lwSetCloserPos(there);
         wwSetCloserPos(there);
     }
     }
}
}
Line 95: Line 99:
         llOwnerSay("state_entry");
         llOwnerSay("state_entry");
         vector here = llGetPos();
         vector here = llGetPos();
         lwSetFarPos(<here.x, here.y, 3000>);
         wwSetFarPos(<here.x, here.y, 3000>);
         lwSetFarPos(<here.x, here.y,  200>);
         wwSetFarPos(<here.x, here.y,  200>);
     }
     }
}
}
</lsl>
</syntaxhighlight>


I'd love to hear what kinds of tests run better with the less simple code posted in the page?
I'd love to hear what kinds of tests run better with the less simple code posted in the page?
Line 105: Line 109:
-- [[User:Ppaatt Lynagh|Ppaatt Lynagh]] 05:39, 1 January 2009 (UTC)
-- [[User:Ppaatt Lynagh|Ppaatt Lynagh]] 05:39, 1 January 2009 (UTC)


: Wrapping lwSetFarPos around lwSetCloserPos may well be exactly what [[User:Jesrad Seraph|Jesrad Seraph]] meant to suggest above ... and [[User:Tatiana Niven|Tatiana Niven]] might have opinions on the best form of { copies = (copies + copies); } ... -- [[User:Ppaatt Lynagh|Ppaatt Lynagh]] 05:58, 1 January 2009 (UTC)
: Wrapping wwSetFarPos around wwSetCloserPos may well be exactly what [[User:Jesrad Seraph|Jesrad Seraph]] meant to suggest above ... and [[User:Tatiana Niven|Tatiana Niven]] might have opinions on the best form of { copies = (copies + copies); } ... -- [[User:Ppaatt Lynagh|Ppaatt Lynagh]] 05:58, 1 January 2009 (UTC)
 
== Test harness for distance limits on llSetPos and alternatives ==
 
Offline I hear tell of mystic syntax errors discouraging newbies from trying the alternatives to llSetPos. Here's a simple test harness I use to try such things out. I did see a mystic syntax error when I first slapped this together, because I forgot the rule that you have to insert the wwWarpPos wwSetFarPos etc. before the default keyword, not after.
 
--[[User:Ppaatt Lynagh|Ppaatt Lynagh]] 06:34, 15 January 2010 (UTC)
 
<syntaxhighlight lang="lsl2">
// Touch to move back and forth, near and far
 
vector leap = < 11, 12, 13 >;
// ... insert wwWarpPos here from http://wiki.secondlife.com/wiki/WarpPos if you want that ...
// ... insert wwSetFarPos wwSetCloserPos wwCopies here from http://wiki.secondlife.com/wiki/Talk:WarpPos if you want those ...
 
// Move far when near and near when far
 
default
{
    touch_start( integer num_detected )
    {
        vector objPos = llGetPos();
        vector aviPos = llDetectedPos( 0 );
        float dist = llVecDist( aviPos, objPos );
 
        float far = llVecMag( leap );
        float near = llVecMag( leap / far );
        float fuzz = 1;
        vector expPos;
        if( dist <= ( near + fuzz ) )
        {
            expPos = ( objPos + leap );
        }
        else
        {
            expPos = ( aviPos + ( leap / far ) );
        }
        float askedDist = llVecDist( objPos, expPos );
       
        llSetPos( expPos );
        //wwSetFarPos( expPos );
        //wwWarpPos( expPos );
 
        vector gotPos = llGetPos();
        float missedDist = llVecDist( expPos, gotPos );
        llOwnerSay( ((string)askedDist) + " leap inaccurate by " + ((string)missedDist) );
    }
}
</syntaxhighlight>


== WarpPos, PosJump or FarPos for SL Vehicles ==
== WarpPos, PosJump or FarPos for SL Vehicles ==
Line 126: Line 180:
<br>
<br>
??
??
: Yes you can use these functions in a vehicle, but this kind of function is not physical movement and it would be cheating in a race. A sit teleporter is really a kind of nonphysical vehicle so it is done all the time. Maybe it can be OK to help you get back a lost vehicle but WarpPos has trouble with ban lines and full parcels when there is not an avatar sitting.  Maybe you can get more help with  instant messages that tell you llGetPos, even if you do try the self return idea. --[[User:Cerise Sorbet|Cerise Sorbet]] 07:30, 15 January 2010 (UTC)
== How about link fast? ==
How about replacing llSetPrimitiveParams( with llSetLinkPrimitiveParamsFast(!!llGetLinkNumber(),  ? --[[User:TigroSpottystripes Katsu|TigroSpottystripes Katsu]] 17:40, 18 May 2010 (UTC)
== Long time buglet ==
The WarpPos code actually has a buglet that's always been present.
The llSetPrimitiveParams call tries to access an element off the end of the list. The final reference to 'count' should be 'count-1'
<syntaxhighlight lang="lsl2">
    llSetPrimitiveParams( rules + llList2List( rules, (count - jumps) << 1, count - 1) );
</syntaxhighlight>
[[User:Omei Qunhua|Omei Qunhua]] 11:40, 14 January 2013 (PST)
Oh! In fact it could be correctly simplified to:-
<syntaxhighlight lang="lsl2">
    llSetPrimitiveParams( rules + llList2List( rules, (count - jumps) << 1, -1) );
</syntaxhighlight>
LOL
[[User:Omei Qunhua|Omei Qunhua]] 11:45, 14 January 2013 (PST)
For the final fail-safe, I would suggest:-
<syntaxhighlight lang="lsl2">
    while ( llVecDist( llGetPos(), destpos ) > .001  && --jumps) //Failsafe
        llSetPos( destpos );
</syntaxhighlight>
Which would avoid excessive extra llSetPos() once the destination is accurately reached.
[[User:Omei Qunhua|Omei Qunhua]] 11:59, 14 January 2013 (PST)

Latest revision as of 12:11, 3 October 2022

Undocumented?

Is this going to be changed in the future? TxMasterG Ping 18:50, 30 March 2007 (PDT)

The new function llSetRegionPos(vector position) is intended to replace WarpPos.

Note: this new function is already available in SL, thus rendering WarpPos technically obsolete — Gwyneth Llewelyn (talk) 13:11, 3 October 2022 (PDT)

See Also

People interested in this exploit may also find posJump to be of interest. A much more efficient method of tricking an object into jumping to some arbitrary position.

Untested?

For moving about a sandbox, this works fine, and that's all I wanted from it ... but I see 2006-05 quote suggesting we could learn more with more test ... and I notice that sitting on an object that moves this way into random positions does seem to confuse the client and/or the server. In prticular, moving to off-world positions leaves the client thinking the agent is still on the object, but then errors start cropping up, things like can't save the edited script because the object is somehow lost to the server while yet existing in the client ...

Script run-time error: Stack-Heap Collision

I do now see "Script run-time error": "Stack-Heap Collision" when I try to jump too far, for example:

default
{
    state_entry()
    {
        llOwnerSay("state_entry");
        vector here = llGetPos();
        warpPos(<here.x, here.y,  200>);
        warpPos(<here.x, here.y, 3000>); // Script run-time error: Stack-Heap Collision
        warpPos(<here.x, here.y,  200>);
    }
}

My Server: Second Life Server 1.24.10.106829

My Client: Second Life 1.21.6 (99587) Oct 14 2008 17:42:25 (Second Life Release)

-- Ppaatt Lynagh 05:25, 1 January 2009 (UTC)

Buggy!

Wow, this thing has one huge bug, which will lead to a stack-heap collision even over a small distance. Appending the "rules" list to itself for the number of jumps is wrong. You need a prototype list to append to the actual rules list. -- Deanfred Brandeis

I think you have LSL confused with a real programing language, LSL operations are pass by value, you aren't appending it to itself you are appending a copy of it to itself. The only stack-heap collision issues arise from not having enough memory available to build the list. The method used here is the most efficient. Strife Onizuka 11:19, 9 April 2007 (PDT)
What about calling the warppos function again using (0.5 * (target + llGetPos())) as new target if the number of jumps is too high ? " if (jumps > 100 ) warppos(0.5 * (destpos + llGetPos())); " That would recursively divide the distance in digestible chunks between large list allocations. I'm not able to test it just yet, will keep you informed.--Jesrad Seraph 03:04, 20 April 2007 (PDT)

The code no longer appears to be the most efficient when compiled as Mono. When compiled as Mono, I no longer see any memory advantage at all to using the code: rules = (rules=[]) + rules + rules; in comparison to the code: rules+=rules; However I seem to be able to get += to double lists in under 60% of the time in my tests. I'm not suggesting changing the code in the article at the moment (because the advantage of the current code to people *not* compiling in Mono is pretty critical, and the benefit to people compiling under Mono isn't exactly huge.) --Tatiana Niven 16:00, 29 August 2008 (AEST) :P

Why Not Simplify

Here's a variation that works better at my desk:

list wwCopies(list copy, integer count)
{
    if(count <= 0)
    {
        return [];
    }
    else
    {
        list copies = copy;
        integer length = 1;
        while(length < count)
        {
            copies = (copies + copies);
            length *= 2; // Overflows when count large
        }
        return llList2List(copies, 0, (llGetListLength(copy) * count) - 1 );
    }
}

wwSetCloserPos(vector there)
{
    list command = [PRIM_POSITION, there];
    float distance = llVecDist(llGetPos(), there);
    if(1000.0 < distance) { distance = 1000.0; } // Script run-time error/ Stack-Heap Collision if too far away
    llSetPrimitiveParams(wwCopies(command, 1 + (integer)(distance / 10.0)));
} 

wwSetFarPos(vector there)
{
    float distance = llVecDist(llGetPos(), there);
    integer tries = (1 + (integer)(distance / 1000.0));
    while(tries--)
    {
        wwSetCloserPos(there);
    }
}

default
{
    state_entry()
    {
        llOwnerSay("state_entry");
        vector here = llGetPos();
        wwSetFarPos(<here.x, here.y, 3000>);
        wwSetFarPos(<here.x, here.y,  200>);
    }
}

I'd love to hear what kinds of tests run better with the less simple code posted in the page?

-- Ppaatt Lynagh 05:39, 1 January 2009 (UTC)

Wrapping wwSetFarPos around wwSetCloserPos may well be exactly what Jesrad Seraph meant to suggest above ... and Tatiana Niven might have opinions on the best form of { copies = (copies + copies); } ... -- Ppaatt Lynagh 05:58, 1 January 2009 (UTC)

Test harness for distance limits on llSetPos and alternatives

Offline I hear tell of mystic syntax errors discouraging newbies from trying the alternatives to llSetPos. Here's a simple test harness I use to try such things out. I did see a mystic syntax error when I first slapped this together, because I forgot the rule that you have to insert the wwWarpPos wwSetFarPos etc. before the default keyword, not after.

--Ppaatt Lynagh 06:34, 15 January 2010 (UTC)

// Touch to move back and forth, near and far

vector leap = < 11, 12, 13 >;
 
// ... insert wwWarpPos here from http://wiki.secondlife.com/wiki/WarpPos if you want that ...
 
// ... insert wwSetFarPos wwSetCloserPos wwCopies here from http://wiki.secondlife.com/wiki/Talk:WarpPos if you want those ...

// Move far when near and near when far

default
{
    touch_start( integer num_detected )
    {
        vector objPos = llGetPos();
        vector aviPos = llDetectedPos( 0 );
        float dist = llVecDist( aviPos, objPos );

        float far = llVecMag( leap );
        float near = llVecMag( leap / far );
        float fuzz = 1;
        vector expPos;
        if( dist <= ( near + fuzz ) )
        {
            expPos = ( objPos + leap );
        }
        else
        {
            expPos = ( aviPos + ( leap / far ) );
        }
        float askedDist = llVecDist( objPos, expPos );
        
        llSetPos( expPos );
        //wwSetFarPos( expPos );
        //wwWarpPos( expPos );

        vector gotPos = llGetPos();
        float missedDist = llVecDist( expPos, gotPos );
        llOwnerSay( ((string)askedDist) + " leap inaccurate by " + ((string)missedDist) );
    }
}

WarpPos, PosJump or FarPos for SL Vehicles

I've been searching a long while for a new and quicker method of getting around in SL. I usually frequent racing SIMs, using Motorcycle or Vehicle Scripts that have limitations in speed or speed being physics or jump limits i hear about, although i'm sure using ---Pos if possible, can it be modified to use as a for example, Drag Racing Vehicle. I usually, top out at a certain speeds, rumor is that only certain speeds such as 500mph or around 600mph can be reached with the other scripts currently found in SL .... ---Pos sounds really exciting...

if not can it be possible to at least mold ----Pos as a kind of auto set home and return... i can't mention the amount of times Racers fall off of sims or go off course or get stuck in a spot, wall, etc and Pos offers a real quick return to a set position while sitting, to return you and vehicle to a desired coordinate either via chat or a gesture on a channel the script will listen to...

1. Pos Vehicle Script
2. Pos Vehicle return to position

Pos... with no limits i'm sure the bar will be raised... ///

...is it out there already?
...are either of these possibilities achievable?
...and how soon can i be breaking speed records... :)
??

Yes you can use these functions in a vehicle, but this kind of function is not physical movement and it would be cheating in a race. A sit teleporter is really a kind of nonphysical vehicle so it is done all the time. Maybe it can be OK to help you get back a lost vehicle but WarpPos has trouble with ban lines and full parcels when there is not an avatar sitting. Maybe you can get more help with instant messages that tell you llGetPos, even if you do try the self return idea. --Cerise Sorbet 07:30, 15 January 2010 (UTC)

How about link fast?

How about replacing llSetPrimitiveParams( with llSetLinkPrimitiveParamsFast(!!llGetLinkNumber(),  ? --TigroSpottystripes Katsu 17:40, 18 May 2010 (UTC)

Long time buglet

The WarpPos code actually has a buglet that's always been present.

The llSetPrimitiveParams call tries to access an element off the end of the list. The final reference to 'count' should be 'count-1'

     llSetPrimitiveParams( rules + llList2List( rules, (count - jumps) << 1, count - 1) );

Omei Qunhua 11:40, 14 January 2013 (PST)

Oh! In fact it could be correctly simplified to:-

     llSetPrimitiveParams( rules + llList2List( rules, (count - jumps) << 1, -1) );

LOL

Omei Qunhua 11:45, 14 January 2013 (PST)

For the final fail-safe, I would suggest:-

     while ( llVecDist( llGetPos(), destpos ) > .001  && --jumps) //Failsafe
         llSetPos( destpos );

Which would avoid excessive extra llSetPos() once the destination is accurately reached.

Omei Qunhua 11:59, 14 January 2013 (PST)