Skip to content
lsl.devlsl.devLSL Dev

LlSameGroup

Looking for the current API? Open the llSameGroup reference →

Function notes

This function compares the group-uuid of the prim containing the script to that of the group-uuid of what uuid describes.
It answers these two questions:
  • "Is the script's prim in the same group as uuid?"
  • "Is the group-uuid of the script's prim equal to uuid?"

Return value notes

Returns an integer that is TRUE if uuid and the prim the script is in are of the same group, otherwise FALSE.

Specification

The group of the prim the script is in is...
  • The group the prim is set-to
  • The group the prim is deeded-to
  • The group the prim is otherwise owned by
  • If no group information is set, the group-uuid used for this is NULL_KEY.
The group of the uuid is...
  • If uuid is a prim (known to the region)...
    • and it is an attachment, the active group of the owner*
    • The group the prim is set-to
    • The group the prim is deeded-to
    • The group the prim is otherwise owned by
    • If no group information is set, the group-uuid used for this is NULL_KEY.
  • If uuid is an avatar (known to the region)...
    • The active group of the avatar.
    • If no group information is set, the group-uuid used for this is NULL_KEY.
  • Otherwise, treat uuid AS the group-uuid.
    • This means that instead of doing "Is the script's prim in the same group as uuid?", it becomes "Is the group-uuid of the script's prim equal to uuid?"
Note: No group, prim, or avatar share the same uuid.
In pseudocode:
integer llSameGroup(key uuid){
    key group = getGroupKey(llGetKey());
    if(uuid == group)
        return TRUE;
    if(getGroupKey(uuid) == group)
        return TRUE;
    return FALSE;
}

Caveats

  • Not so obvious is that it returns TRUE if the object is not set to a group (i.e. "(none)") and either the AV with the given key has no group active or the function is called with a NULL_KEY.

Examples

// Gives inventory object only to agents with the same active group

default
{
    touch_start(integer total_number)
    {
        key id = llDetectedKey(0);

        integer sameGroup = llSameGroup(id);
//      same as llDetectedGroup(i) (with llDetectedGroup, detected does not need to be in the sim)

        if (sameGroup)
        {
            integer numberOfObjectsInPrim = llGetInventoryNumber(INVENTORY_OBJECT);

            if (numberOfObjectsInPrim)
                llGiveInventory(id, llGetInventoryName(INVENTORY_OBJECT, 0));
        }
        else
        {
            llRegionSayTo(id, 0, "Wrong active group!");
        }
    }
}

Helper functions

To determine if an avatar is an object's owner when deeded to group, you should use a function similar to that provided for llGetOwner().
The following uses llSameGroup() to determine if a parcel is rezzable based on the object's active group and parcel details. Useful for preventing unnecessary rez failure notices from various types of attached objects (e.g. guns, water/skywalk HUDs, etc).
/*
  By Aryn Gellner
  pos - position (in region coordinates) to check against.
  * Additional Land Owner Test added by Ruthven Willenov, simplified by Strife
*/
 
integer is_rezzable(vector pos)
{
    integer parcel_flags = llGetParcelFlags(pos);
    if (parcel_flags & PARCEL_FLAG_ALLOW_CREATE_OBJECTS)
    {
        return true; //Anyone can rez. No further checks are needed.
    }

    //Ok, not just anyone can rez. Maybe they share an owner or the land allows for group rezzing.
    //So let's get the parcel owner_id and group_id

    list details = llGetParcelDetails(pos, [PARCEL_DETAILS_OWNER, PARCEL_DETAILS_GROUP]);

    if (llList2Key(details, 0) == llGetOwner())
    {
        return TRUE; //Owner can always rez.
    }

    //Since what we are going to return is a boolean just return the result of the boolean expression.
    return (parcel_flags & PARCEL_FLAG_ALLOW_CREATE_GROUP_OBJECTS) && llSameGroup(llList2Key(details, 1));
}

See also: functions

Tests

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/uuid

Original shared helper source (conditional wiki logic is not evaluated)
<noinclude>{{Multi-lang|category=LSL}}</noinclude>{{LSL Injection Test}}{{#if:

{{#vardefine:p_{{{1|none}}}_desc|{{#if:{{{pd|}}}|{{{pd|}}}&#32;}}{{#if:{{{group|1}}}|{{LSLGC|Group|group}},&#32;}}{{LSLGC|Avatar|avatar}} or {{#if:{{{object|}}}|[[object]]|[[prim]]}} {{HoverLink|UUID|Universally Unique Identifier}} {{#if:{{{sim|}}}|that is in the same [[region]] {{#switch:{{{sim|}}}|*=|#default = &#32;{{{sim|}}}}}
}}}}

{{#vardefine:p_{{{1|none}}}_hover|{{#if:{{{ph|}}}|{{{ph|}}}&#32;|{{#if:{{{pd|}}}|{{{pd|}}}&#32;}}}}{{#if:{{{group|1}}}|group,&#32;}}avatar or {{#if:{{{object|}}}|object|prim}} UUID {{#if:{{{sim|}}}|that is in the same region {{#switch:{{{sim|}}}|*=|#default = &#32;{{{sim|}}}}}
}}}}

<includeonly>
{{#ifeq:{{#var:article-type}}|event||{{#if:{{#pos:{{#var:moded}}|r}}{{#pos:{{#var:moded}}|u}}||{{#vardefine:hidden-text|{{#var:hidden-text}}
{{LSLC|Avatar/As A Parameter}}
}}}}}}
</includeonly>

}}<noinclude>
{| {{Prettytable}}
|-{{Hl2}}
!var
!value
|-
|desc
|{{#var:p_{{{1|none}}}_desc}}
|-
|hover
|{{#var:p_{{{1|none}}}_hover}}
|}
</noinclude>

Template:LSL Function/group

Original shared helper source (conditional wiki logic is not evaluated)
{{LSL Injection Test}}{{#if:

{{Issues/VWR-5044}}

{{#vardefine:notes|{{#var:notes}}{{PBR}}
==== Child Prims ====
It is possible for the group of a child prim to differ from that of the root prim. To build such an object it must first be unlinked, the groups set, and then relinked. Rezzing an object resets the group of the object to that of the group that the user currently has activated. Changing the group of an object changes the group for the entire object. This may only be an artifact or manifestation of [[#VWR-5044|VWR-5044]].}}

}}<noinclude>{{#vardefine:notes}}
{| {{Prettytable}}
|+<code><nowiki>{{{{FULLPAGENAMEE}}|}}</nowiki></code>{{{{FULLPAGENAMEE}}|}}
|-{{Hl2}}
! #var
! value
|-
{{VarPair|notes}}
|-
{{VarPairTable|issues}}
|-
{{VarPair|BugCounter}}
|-
{{VarPair|IssueCounter}}
|}
</noinclude>
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.