Unofficial LSL Reference

[[functions:llsamegroup]]


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

This is an old revision of the document!


Function: llSameGroup

integer llSameGroup(key id)

Return whether the given object or avatar has the same active group as the current prim.

Parameters

id

The key of an avatar or a prim in the same region.

Result

Returns TRUE if the user defined by id has the same group active that the prim with this script is assigned to, or deeded to, or if the object of key id is assigned to the same group. Returns FALSE if the user or object is not currently in the same region, or if the assigned group differs.

Notes

  • This function will also return TRUE if the user/object of key id has no active group, and the prim containing the script is not assigned to any group.
  • TRUE is also returned if this object is not assigned to any group, and the function is called with NULL_KEY.
  • An object MAY be constructed from several prims each assigned to a different group. However, if the built object is then assigned to a new group, each component prim will be reassigned.

Short examples

integer Same = llSameGroup(llGetOwner()); // Same will be TRUE if the object owner's currently active group is the same as that which the touched prim is assigned to, and the owner is currently in the region.

Complete examples

The following script will periodically check if the owner's active group is the same as the current one, and tell them.

llSameGroup-example.lsl
integer PreviousSameGroup = -1; // set it to a value that is neither TRUE nor FALSE

default
{
    state_entry()
    {
        llSetTimerEvent(20); // check every 20 seconds
    }

    timer()
    {
        integer CurrentSameGroup = llSameGroup(llGetOwner());
        // Only act when the value changes.
        if (CurrentSameGroup != PreviousSameGroup)
        {
            if (CurrentSameGroup)
                llOwnerSay("Your active group matches this object's group.");
            else
                llOwnerSay("Your active group does not match this object's group.");

            // Remember current value for the next iteration.
            PreviousSameGroup = CurrentSameGroup;
        }
    }
}

See also