Table of Contents

Start Functions Events Constants Types Language Articles

Function: llAvatarOnSitTarget

key llAvatarOnSitTarget()

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

Return value

The key of the avatar occupying the sit target of the prim the script is in, or NULL_KEY if none.

Notes

Short examples

llOwnerSay(llAvatarOnSitTarget()); // Displays the key of the avatar occupying the sit target of this prim.

Complete examples

Here's a script that restricts the sit target for the prim the script is dropped into, so that it can only be occupied by the owner of the prim.

llAvatarOnLinkSitTarget-example.lsl
default
{
    state_entry()
    {
        // Set a sit target for this prim, so we can use llAvatarOnSitTarget
        // to detect if an agent sat on it.
        llSitTarget(<0, 0, 1>, ZERO_ROTATION);
    }

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

See also