Difference between revisions of "LlGetLocalPos"

From Second Life Wiki
Jump to navigation Jump to search
m (The function was vague and wouldn't work on child prims)
m (Minor LSL style editing (to make it uniform with the rest of the LSL Portal))
 
(3 intermediate revisions by 3 users not shown)
Line 10: Line 10:
|constants
|constants
|examples=
|examples=
<lsl>
<syntaxhighlight lang="lsl2">
default
default
{
{
  touch_start( integer vIntTouched )
    touch_start(integer vIntTouched)
  {
    string vStrMessage = "The touched prim is ";
    if (llDetectedLinkNumber( 0 ) > 1)
     {
     {
      vStrMessage += (string)llVecMag( llGetLocalPos() ) + "m from ";
        string vStrMessage = "The touched prim is ";
        if (llDetectedLinkNumber(0) > 1)
        {
            vStrMessage += (string)llVecMag(llGetLocalPos()) + "m from ";
        }
        llSay(0, vStrMessage + "the root prim");
     }
     }
    llSay( 0, vStrMessage + "the root prim" );
  }
}
}
</lsl>
</syntaxhighlight>
|helpers=
|helpers=
There is no function to set the position of a prim local to itself.
There is no function to set the position of a prim local to itself.
To set the position of a prim local to itself you would have to do something like:
To set the position of a prim local to itself you would have to do something like:
<lsl>
<syntaxhighlight lang="lsl2">
SetPositionLocalToCurrentPosition(vector local_position)
SetPositionLocalToCurrentPosition(vector local_position)
{
{
  llSetPos(llGetLocalPos() + (local_position * llGetLocalRot()));
    llSetPos(llGetLocalPos() + (local_position * llGetLocalRot()));
}
}
</lsl>
</syntaxhighlight>
Or:
<syntaxhighlight lang="lsl2">
SetPositionLocalToCurrentPosition(vector local_position)
{
    llSetPos(llGetPos() + (local_position * llGetRot()));
}
</syntaxhighlight>
|also_functions={{LSL DefineRow||[[llGetRootPosition]]|Gets the root prims global position}}
|also_functions={{LSL DefineRow||[[llGetRootPosition]]|Gets the root prims global position}}
{{LSL DefineRow||[[llGetPos]]|Gets the prims global position}}
{{LSL DefineRow||[[llGetPos]]|Gets the prims global position}}
Line 40: Line 47:
|also_articles
|also_articles
|notes
|notes
|haiku={{Haiku|Root's vector winks,|Lost in local's labyrinth,|Attach point's secret.|author=ChatGPT}}
|cat1=Movement
|cat1=Movement
|cat2=Prim
|cat2=Prim

Latest revision as of 08:29, 27 May 2024

Summary

Function: vector llGetLocalPos( );
0.0 Forced Delay
10.0 Energy

Returns a vector that is the position relative (local) to the root.

If called from the root prim it returns the position in the region unless it is attached to which it returns the position relative to the attach point.

Examples

default
{
    touch_start(integer vIntTouched)
    {
        string vStrMessage = "The touched prim is ";
        if (llDetectedLinkNumber(0) > 1)
        {
            vStrMessage += (string)llVecMag(llGetLocalPos()) + "m from ";
        }
        llSay(0, vStrMessage + "the root prim");
    }
}

Useful Snippets

There is no function to set the position of a prim local to itself. To set the position of a prim local to itself you would have to do something like:

SetPositionLocalToCurrentPosition(vector local_position)
{
    llSetPos(llGetLocalPos() + (local_position * llGetLocalRot()));
}

Or:

SetPositionLocalToCurrentPosition(vector local_position)
{
    llSetPos(llGetPos() + (local_position * llGetRot()));
}

See Also

Functions

•  llGetRootPosition Gets the root prims global position
•  llGetPos Gets the prims global position
•  llSetPos Sets the prims global position

Deep Notes

Signature

function vector llGetLocalPos();

Haiku

Root's vector winks,
Lost in local's labyrinth,
Attach point's secret.
— ChatGPT