Difference between revisions of "LlGetPos"

From Second Life Wiki
Jump to navigation Jump to search
m (Fix: some stupid syntax errors (= bad copy&pasting))
 
(29 intermediate revisions by 14 users not shown)
Line 1: Line 1:
{{LSL_Function
{{LSL_Function
|func_id=59|func_sleep=0.0|func_energy=10.0
|func_id=59|func_sleep=0.0|func_energy=10.0
|func=llGetPos
|func=llGetPos|sort=GetPos
|return_type=vector
|return_type=vector
|func_footnote
|func_footnote
|func_desc
|func_desc
|return_text=that is the prim's [[Viewer coordinate frames#Region|region]] position
|Return_text=position of the task in [[Viewer coordinate frames#Region|region]] coordinates
|spec
|spec
|caveats
|caveats=*When called from the root of an attachment, returns the wearer's region position. To see the position used, enable '''Develop>Avatar>Display Agent Target''' and use the red crosshair. If the avatar is sitting on an object, the red crosshair may be hidden by the white one, in the same position.
 
*When called in an attachment's child prim, the position given is again relative to the ''avatar's'' root position and rotation, but with the offset from the root prim added. Visually, the reported position will only be correct if the object's root is attached to [[ATTACH_AVATAR_CENTER]], at [[ZERO_ROTATION]] and [[ZERO_VECTOR]]. Moving the attachment's root or changing the attachment point will not affect the reported position. Avatar animation is invisible to the simulator, so it also does not affect the reported position.
|constants
|constants
|examples
|examples=<syntaxhighlight lang="lsl2">default
{
    touch_start(integer total_number)
    {
        // When touched, check the position of
        // the object, save it to "position",
        // then convert it into a string and
        // say it.
        vector position = llGetPos();
        llSay(0, (string)position);
    }
}</syntaxhighlight>
<syntaxhighlight lang="lsl2">default
{
    on_rez(integer param)
    {
        // Adding .x .y or .z after the vector name can be used to get the float value of just that axis.
        vector pos = llGetPos();
        float Z = pos.z; // <--- Like this.
        if(Z > 500.0)
        llOwnerSay("Oooh! I'm up high!");
    }
}</syntaxhighlight>
|helpers
|helpers
|also_functions={{LSL DefineRow||[[llGetLocalPos]]|Gets the [[Viewer coordinate frames#Local|local]] position}}
|also_functions=
{{LSL DefineRow||[[llGetLocalPos]]|Gets the prim [[Viewer coordinate frames#Local|local]] position}}
{{LSL DefineRow||[[llGetPrimitiveParams]]|Gets prim properties}}
{{LSL DefineRow||[[llGetRootPosition]]|Gets the root prims position}}
{{LSL DefineRow||[[llSetPos]]|Sets the prim position}}
{{LSL DefineRow||[[llSetPrimitiveParams]]|Sets prim properties}}
{{LSL DefineRow||[[llSetLinkPrimitiveParams]]|Sets linked prim properties}}
|also_tests
|also_tests
|also_events
|also_events
Line 17: Line 47:
|notes
|notes
|cat1=Movement
|cat1=Movement
|cat2
|cat2=Prim
|cat3
|cat3
|cat4
|cat4
|haiku={{Haiku|Remote yesteryear|A precise position shows|out of primitive}}
}}
}}

Latest revision as of 13:51, 17 April 2022

Summary

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

Returns the vector position of the task in region coordinates

Caveats

  • When called from the root of an attachment, returns the wearer's region position. To see the position used, enable Develop>Avatar>Display Agent Target and use the red crosshair. If the avatar is sitting on an object, the red crosshair may be hidden by the white one, in the same position.
  • When called in an attachment's child prim, the position given is again relative to the avatar's root position and rotation, but with the offset from the root prim added. Visually, the reported position will only be correct if the object's root is attached to ATTACH_AVATAR_CENTER, at ZERO_ROTATION and ZERO_VECTOR. Moving the attachment's root or changing the attachment point will not affect the reported position. Avatar animation is invisible to the simulator, so it also does not affect the reported position.

Examples

default
{
    touch_start(integer total_number)
    {
        // When touched, check the position of
        // the object, save it to "position",
        // then convert it into a string and
        // say it.
        vector position = llGetPos();
        llSay(0, (string)position);
    }
}
default
{
    on_rez(integer param)
    {
        // Adding .x .y or .z after the vector name can be used to get the float value of just that axis.
        vector pos = llGetPos();
        float Z = pos.z; // <--- Like this.
        if(Z > 500.0)
        llOwnerSay("Oooh! I'm up high!");
    }
}

See Also

Functions

•  llGetLocalPos Gets the prim local position
•  llGetPrimitiveParams Gets prim properties
•  llGetRootPosition Gets the root prims position
•  llSetPos Sets the prim position
•  llSetPrimitiveParams Sets prim properties
•  llSetLinkPrimitiveParams Sets linked prim properties

Deep Notes

Signature

function vector llGetPos();

Haiku

Remote yesteryear
A precise position shows
out of primitive