Difference between revisions of "LlGetLocalPos"
Jump to navigation
Jump to search
Void Singer (talk | contribs) (added also functions get root pos, tweaked.) |
m |
||
(8 intermediate revisions by 5 users not shown) | |||
Line 10: | Line 10: | ||
|constants | |constants | ||
|examples= | |examples= | ||
< | <source lang="lsl2"> | ||
default | default | ||
{ | |||
touch_start( integer vIntTouched ) | touch_start( integer vIntTouched ) | ||
{ | |||
string vStrMessage = "The touched prim is "; | string vStrMessage = "The touched prim is "; | ||
if (llDetectedLinkNumber( 0 ) > 1){ | if (llDetectedLinkNumber( 0 ) > 1) | ||
vStrMessage += (string)llVecMag( llGetLocalPos() ) + "m from " | { | ||
vStrMessage += (string)llVecMag( llGetLocalPos() ) + "m from "; | |||
} | } | ||
llSay( 0, vStrMessage + "the root prim" ); | llSay( 0, vStrMessage + "the root prim" ); | ||
} | } | ||
} | } | ||
</ | </source> | ||
|helpers= | |helpers= | ||
There is no | There is no function to set the position of a prim local to itself. | ||
To set the position of a | To set the position of a prim local to itself you would have to do something like: | ||
< | <source lang="lsl2"> | ||
SetPositionLocalToCurrentPosition(vector local_position) | |||
{ | |||
llSetPos(llGetLocalPos() + (local_position * llGetLocalRot())); | |||
} | |||
</source> | |||
Or: | |||
<source lang="lsl2"> | |||
SetPositionLocalToCurrentPosition(vector local_position) | |||
{ | { | ||
llSetPos(llGetPos() + (local_position * llGetRot())); | |||
} | } | ||
</ | </source> | ||
|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}} | ||
{{LSL DefineRow||[[llSetPos]]|Sets the prims | {{LSL DefineRow||[[llSetPos]]|Sets the prims global position}} | ||
|also_tests | |also_tests | ||
|also_events | |also_events | ||
Line 41: | Line 49: | ||
|cat1=Movement | |cat1=Movement | ||
|cat2=Prim | |cat2=Prim | ||
|cat3 | |cat3 | ||
|cat4 | |cat4 | ||
}} | }} |
Latest revision as of 02:10, 22 January 2015
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Summary
Function: vector llGetLocalPos( );60 | Function ID |
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.
Caveats
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 |