Skip to content
lsl.devlsl.devLSL Dev

LlSetRegionPos

Looking for the current API? Open the llSetRegionPos reference →

Wiki description

Tries to move the entire object so that the root prim is within 0.1m of position.

Function notes

Only if TRUE is returned does the object move, if FALSE is returned, the object does not change position. (Spec does not quite agree, if object tries to go underground, the spec says it moves to ground level with the provided X and Y.)

Return value notes

Returns an integer , TRUE if the object is successfully placed within 0.1 m of position, FALSE otherwise. See for details.

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].
      • 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 if the position is a point more than 0.1 m below region ground level, but the object will still be moved so that the midpoint of the root prim is snapped to the ground. If the point is less than 0.1 m below ground, the object is moved as before and TRUE is returned as per the first case.

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

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.

Shared wiki helpers

The original page also injects shared parameter notes, caveats or issue information through these helpers. Their conditional MediaWiki logic is not reproduced here; inspect the preserved helper source for additional material.

Template:LSL Function/position

Original shared helper source (conditional wiki logic is not evaluated)
{{LSL Injection Test}}<noinclude>
This template is to be used to specify setup the description for position like parameters (offsets, positions, points, etc.).

Right now it's pretty basic and easy to edit. I'm wondering if these functions should be in a position parameter specific category.

====TODO====
* add clamping flag and verbiage for out of region/range coordinates.
</noinclude>{{#if:

{{#if:{{{region|}}}|
  {{#if:{{{local|}}}|

    {{#vardefine:p_{{{1|}}}_desc|position in {{HoverLink|Viewer coordinate frames#Region|Origin is the origin of the region which {{String|owns}} the object.|region}} or [[Viewer coordinate frames#Local|local coordinates]] depending upon the situation{{{desc|}}}}}

    {{#vardefine:p_{{{1|}}}_hover|position in region or local coordinates depending upon the situation{{#if:{{{hover|}}}|{{{hover|}}}|{{{desc|}}}}}}}

  |
    {{#ifeq:{{{1|}}}|point|

      {{#vardefine:p_{{{1|}}}_desc|A point in {{HoverLink|Viewer coordinate frames#Region|Origin is the origin of the region which {{String|owns}} the object.|region-local}} space{{#ifeq:{{{region|}}}|noZ|&#32;(z component is ignored)}}{{{desc|}}}}}

      {{#vardefine:p_{{{1|}}}_hover|A point in region-local space{{#ifeq:{{{region|}}}|noZ|&#32;(z component is ignored)}}{{#if:{{{hover|}}}|{{{hover|}}}|{{{desc|}}}}}}}

    |

      {{#vardefine:p_{{{1|}}}_desc|position in {{HoverLink|Viewer coordinate frames#Region|Origin is the origin of the region which {{String|owns}} the object.|region coordinates}}{{#ifeq:{{{region|}}}|noZ|&#32;(z component is ignored)}}{{{desc|}}}}}

      {{#vardefine:p_{{{1|}}}_hover|position in region coordinates{{#ifeq:{{{region|}}}|noZ|&#32;(z component is ignored)}}{{#if:{{{hover|}}}|{{{hover|}}}|{{{desc|}}}}}}}

    }}
  }}
|
  {{#if:{{{local|}}}|

    {{#ifeq:{{{1|}}}|offset|

      {{LSL Function/offset|{{{1|}}}|local={{{local}}}}}

    |

      {{#vardefine:p_{{{1|}}}_desc|position in [[Viewer coordinate frames#Local|local coordinates]]{{{desc|}}}}}

      {{#vardefine:p_{{{1|}}}_hover|position in local coordinates{{#if:{{{hover|}}}|{{{hover|}}}|{{{desc|}}}}}}}

    }}
  }}
}}

}}
Original wiki source

Some wiki templates and tables need their original context. View this article on the Second Life Wiki. Technical wording and examples are retained from the source; historical guidance may differ from current behavior.