Unofficial LSL Reference

[[functions:llavataronlinksittarget]]


Unofficial LSL reference

User Tools

Login

You are currently not logged in! Enter your authentication credentials below to log in. You need to have cookies enabled to log in.

Login

Forgotten your password? Get a new one: Set new password

Function: llAvatarOnLinkSitTarget

key llAvatarOnLinkSitTarget(integer link)

Get the key of the avatar occupying the sit target of the given linked prim, or NULL_KEY if none.

Parameters

An integer value defining the link number of the prim to be read. It must specify one single link.

The following special single link specification constants can be used:-

ConstantValueDescription
LINK_THIS -4 refers to the prim the script is in
LINK_ROOT 1 refers to the root prim in a multi-prim linked set

Return value

The key of the avatar occupying the sit target of the prim in the given link number, or NULL_KEY if none.

Notes

  • Sitting on a single prim effectively makes a linked object of two prims. That makes the root prim immediately change its number from 0 to 1, therefore checking llAvatarOnLinkSitTarget(0) makes no sense for single prims.
  • This function will also return NULL_KEY if there is no sit target set for the given link, even if there is someone sitting in the prim.
  • NULL_KEY is also returned if the link number is positive and out of range.
  • If the script is in the root prim:
    • Any link number between -2147483646 and -1 other than LINK_THIS (-4) seems to refer to link 2.
    • Link numbers 0, -2147483647 and -2147483648 return NULL_KEY.
  • If the script is in a child prim:
    • Any link number between -2147483647 and 1 other than LINK_THIS (-4) seems to refer to the root prim. (The official wiki incorrectly states that llAvatarOnLinkSitTarget(0) will always be NULL_KEY. That is only true for scripts that are in a single prim object or in the root prim of a linkset.)
    • Link number -2147483648 returns NULL_KEY.

Short examples

llOwnerSay(llAvatarOnLinkSitTarget(2)); // Displays the key of the avatar occupying the sit target of link number 2

Complete examples

Here's a script that restricts the sit target for link 3 so that it can only be occupied by the owner of the prim.

llAvatarOnLinkSitTarget-example.lsl
default
{
    state_entry()
    {
        // Set a sit target for link 3, so we can use llAvatarOnLinkSitTarget
        // to detect whether an agent sat on it.
        llLinkSitTarget(3, <0, 0, 1>, ZERO_ROTATION);
    }

    changed(integer change)
    {
        if (change & CHANGED_LINK)
        {
            key id = llAvatarOnLinkSitTarget(3); // read who is sitting on prim 3, if anyone
            if (id != llGetOwner() && id != NULL_KEY)
            {
                llUnSit(id);
                llRegionSayTo(id, 0, "This seat is reserved for the owner only!");
            }
        }
    }
}

See also