Difference between revisions of "LlGetPos"

From Second Life Wiki
Jump to navigation Jump to search
m (Added example to show how to access each float (.x etc))
m (Altered an example.)
Line 26: Line 26:
     on_rez(integer param)
     on_rez(integer param)
     {
     {
         // Access each of the floats in a vector separately.
         // Adding .x .y or .z after the vector name can be used to get the float value of just that axis.
         vector pos = llGetPos();
         vector pos = llGetPos();
        float X = pos.x;
         float Z = pos.z; // <--- Like this.
        float Y = pos.y;
        if(Z > 500.0)
         float Z = pos.z;
        llOwnerSay("Oooh! I'm up high!");
        llSetPos(<(X - 2.0), Y, (Z + 10.0)>);
     }
     }
}</lsl>
}</lsl>

Revision as of 18:04, 12 March 2010

Summary

Function: vector llGetPos( );

Returns a vector that is the the position of the task in region coordinates

Caveats

  • When called from the root of an attachment, returns the wearer's position. When called in any child prim, always returns that prim's region position.
All Issues ~ Search JIRA for related Bugs

Examples

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

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

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

Search JIRA for related Issues

Signature

function vector llGetPos();