Difference between revisions of "LlSetRegionPos"

From Second Life Wiki
Jump to navigation Jump to search
m (forgot)
m (Replaced <source> with <syntaxhighlight>)
 
(14 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{LSL Function
{{LSL Function
|mode=pre-release
|inject-2={{LSL_Function/position|position|region=*}}
|func_id=?|func_sleep=0.0|func_energy=0.0
|func_id=?|func_sleep=0.0|func_energy=0.0
|func=llSetRegionPos
|func=llSetRegionPos
|p1_type=vector|p1_name=position|p1_desc=position in [[Viewer coordinate frames#Region|region coordinates]]|p1_hover=position in region coordinates
|p1_type=vector|p1_name=position
|return_type=integer
|return_type=integer
|return_text=[[boolean]], [[TRUE]] if the object is successfully placed within 0.1 m of '''{{LSL Param|position}}''', [[FALSE]] otherwise. See [[#Specification]] for details.
|return_text=[[boolean]], [[TRUE]] if the object is successfully placed within 0.1 m of {{LSLP|position}}, [[FALSE]] otherwise. See [[#Specification]] for details.
|func_desc=Tries to moves the entire object so that the root prim is within 0.1m of '''{{LSL Param|position}}'''.
|func_desc=Tries to move the entire object so that the root prim is within 0.1m of {{LSLP|position}}.
|func_footnote=Only if [[TRUE]] is returned does the object move, if [[FALSE]] is returned, the object does not change position.
|func_footnote=Only if [[TRUE]] is returned does the object move, if [[FALSE]] is returned, the object does not change position.
|spec=
|spec=
Line 12: Line 12:
* Returns [[TRUE]] if the object is successfully placed within 0.1 m of position.
* Returns [[TRUE]] if the object is successfully placed within 0.1 m of position.
* Returns [[FALSE]] and does not move the object if...
* Returns [[FALSE]] and does not move the object if...
** '''{{LSL Param|position}}''' is more than 10m off region or above 4096m.
** {{LSLP|position}} is more than 10m off region or above 4096m.
*** The x & y components of '''{{LSL Param|position}}''' must be in the range {{Interval|gte=-10.0|lte=266.0}}.{{Interval/Footnote}}
*** The x & y components of {{LSLP|position}} must be in the range {{Interval|gte=-10.0|lte=266.0}}.{{Interval/Footnote}}
*** The z component must be in the range {{Interval|gte=0.0|lte=4096}}.
*** The z component must be in the range {{Interval|gte=0.0|lte=4096}}.
** the object is dynamic (has [[STATUS_PHYSICS|physics enabled]]).
** the object is dynamic (has [[STATUS_PHYSICS|physics enabled]]).
** the object can not move to position due to parcel/region restrictions (object entry rules, prim limits, bans, etc).
** the object can not move to position due to parcel/region restrictions (object entry rules, prim limits, bans, etc).
** the object is an avatar attachment.
* Returns [[FALSE]] and moves the object if the z position is below the ground .
|caveats=
|caveats=
|constants
|constants
|examples=
|examples=
<syntaxhighlight lang="lsl2">
default
{
    touch_start(integer num_detected)
    {
        vector currentPosition = llGetPos();
        // check whether the object has successfully been moved
        // to the center of the sim at the same height
        integer hasMoved = llSetRegionPos(<128.0, 128.0, currentPosition.z>);
        if (hasMoved)
        {
            llOwnerSay("My new position is now:\n"
                + "http://maps.secondlife.com/secondlife/" + llEscapeURL(llGetRegionName())
                + "/128/128/" + (string)llRound(currentPosition.z) + "/");
        }
        else if ( currentPosition.z < llGround(ZERO_VECTOR) )
        {
            llOwnerSay("My new position is now:\n"
                + "http://maps.secondlife.com/secondlife/" + llEscapeURL(llGetRegionName())
                + "/128/128/" + (string)llCeil(llGround(ZERO_VECTOR)) + "/");
        }
        else
            llOwnerSay("Move was not possible!");
    }
}
</syntaxhighlight>
|helpers
|helpers
|also_functions={{LSL DefineRow||[[llGetLocalPos]]|Returns the prim's local position if it is attached or non-root (otherwise it returns the global position)}}
|also_functions={{LSL DefineRow||[[llGetLocalPos]]|Returns the prim's local position if it is attached or non-root (otherwise it returns the global position)}}
Line 25: Line 56:
{{LSL DefineRow||[[llGetPos]]|Returns the prim's global position, even if it is attached or non-root}}
{{LSL DefineRow||[[llGetPos]]|Returns the prim's global position, even if it is attached or non-root}}
{{LSL DefineRow||[[llSetPos]]|}}
{{LSL DefineRow||[[llSetPos]]|}}
{{LSL DefineRow||[[llEdgeOfWorld]]|}}
|also_tests
|also_tests
|also_events
|also_events
Line 31: Line 63:
This function is intended to replace [[WarpPos]].
This function is intended to replace [[WarpPos]].
|history=
|history=
* New LSL function integer llSetRegionPos(vector position) in Second Life RC BlueSteel 12.01.03.247042
* New LSL function integer llSetRegionPos(vector position) in Second Life Server 12.01.24.248357
*: The object with the script will move the root prim position to the given location. The position is any position within the region. If the position is below ground, it will be set to the ground level at that X,Y spot. The function has no delay or throttle.
*: The object with the script will move the root prim position to the given location. The position is any position within the region. If the position is below ground, it will be set to the ground level at that X,Y spot. The function has no delay or throttle.
*:* Returns 1 if the object is successfully placed within 0.1 m of position.
*:* Returns 1 if the object is successfully placed within 0.1 m of position.

Latest revision as of 02:37, 27 September 2022

Summary

Function: integer llSetRegionPos( vector position );

Tries to move the entire object so that the root prim is within 0.1m of position.
Returns an integer boolean, TRUE if the object is successfully placed within 0.1 m of position, FALSE otherwise. See #Specification for details.

• vector position position in region coordinates

Only if TRUE is returned does the object move, if FALSE is returned, the object does not change position.

Specification

The object with the script will move the root prim position to the given location. The position is any position within the region. If the position is below ground, it will be set to the ground level at that X,Y spot. The function has no delay or throttle.

  • Returns TRUE if the object is successfully placed within 0.1 m of position.
  • Returns FALSE and does not move the object if...
    • position is more than 10m off region or above 4096m.
      • The x & y components of position must be in the range [-10.0, 266.0].[1]
      • The z component must be in the range [0.0, 4096].
    • the object is dynamic (has physics enabled).
    • the object can not move to position due to parcel/region restrictions (object entry rules, prim limits, bans, etc).
    • the object is an avatar attachment.
  • Returns FALSE and moves the object if the z position is below the ground .

Examples

default
{
    touch_start(integer num_detected)
    {
        vector currentPosition = llGetPos();

        // check whether the object has successfully been moved
        // to the center of the sim at the same height
        integer hasMoved = llSetRegionPos(<128.0, 128.0, currentPosition.z>);

        if (hasMoved)
        {
            llOwnerSay("My new position is now:\n"
                + "http://maps.secondlife.com/secondlife/" + llEscapeURL(llGetRegionName())
                + "/128/128/" + (string)llRound(currentPosition.z) + "/");
        }
        else if ( currentPosition.z < llGround(ZERO_VECTOR) )
        {
            llOwnerSay("My new position is now:\n"
                + "http://maps.secondlife.com/secondlife/" + llEscapeURL(llGetRegionName())
                + "/128/128/" + (string)llCeil(llGround(ZERO_VECTOR)) + "/");
        }
        else
            llOwnerSay("Move was not possible!");
    }
}

Notes

This function is intended to replace WarpPos.

See Also

Functions

•  llGetLocalPos Returns the prim's local position if it is attached or non-root (otherwise it returns the global position)
•  llGetRootPosition Gets the root prims position
•  llGetPos Returns the prim's global position, even if it is attached or non-root
•  llSetPos
•  llEdgeOfWorld

Deep Notes

History

  • New LSL function integer llSetRegionPos(vector position) in Second Life Server 12.01.24.248357
    The object with the script will move the root prim position to the given location. The position is any position within the region. If the position is below ground, it will be set to the ground level at that X,Y spot. The function has no delay or throttle.
    • Returns 1 if the object is successfully placed within 0.1 m of position.
    • Returns 0 and does not move the object if position is more than 10m off region or above 4096m.
    • Returns 0 and does not move the object if the object is dynamic (has physics enabled).
    • Returns 0 and does not move the object if the object can not move to position due to object entry rules, prim limits, bans, etc.
Search JIRA for related Issues

Footnotes

  1. ^ The ranges in this article are written in Interval Notation.

Signature

function integer llSetRegionPos( vector position );