Difference between revisions of "LlSameGroup"
Rolig Loon (talk | contribs) |
Aryn Gellner (talk | contribs) (Added a useful tidbit that makes use of llSameGroup()) |
||
Line 40: | Line 40: | ||
} | } | ||
</lsl> | </lsl> | ||
|helpers=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#Useful_Snippets|llGetOwner]](). | |helpers= | ||
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#Useful_Snippets|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). | |||
<lsl> | |||
/* | |||
By Aryn Gellner | |||
pos - position (in region coordinates) to check against. | |||
*/ | |||
integer is_rezzable(vector pos) | |||
{ | |||
key group_id = llList2Key(llGetParcelDetails(pos, [PARCEL_DETAILS_GROUP]), 0); | |||
integer parcel_flags = llGetParcelFlags(pos); | |||
if(parcel_flags & PARCEL_FLAG_ALLOW_CREATE_OBJECTS) | |||
{ | |||
return TRUE; | |||
} | |||
else if((parcel_flags & PARCEL_FLAG_ALLOW_CREATE_GROUP_OBJECTS) && llSameGroup(group_id)) | |||
{ | |||
return TRUE; | |||
} | |||
else | |||
{ | |||
return FALSE; | |||
} | |||
} | |||
</lsl> | |||
|also_functions={{LSL DefineRow||[[llDetectedGroup]]|Used in conjunction with {{LSLGC|Detected|detection}} events}} | |also_functions={{LSL DefineRow||[[llDetectedGroup]]|Used in conjunction with {{LSLGC|Detected|detection}} events}} | ||
|also_tests= | |also_tests= |
Revision as of 14:08, 17 August 2014
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Summary
Function: integer llSameGroup( key uuid );0.0 | Forced Delay |
10.0 | Energy |
Returns an integer boolean, that is TRUE if uuid has the same active group, otherwise FALSE
• key | uuid | – | group, avatar or prim UUID that is in the same region |
Also returns TRUE if the object is deeded to the same active group as uuid Also returns TRUE if the object is "set to" or deeded to the same group as group UUID (i.e. key OBJECT_GROUP)
Caveats
Examples
<lsl> // 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!"); } }
}
</lsl>Useful Snippets
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). <lsl> /*
By Aryn Gellner pos - position (in region coordinates) to check against.
- /
integer is_rezzable(vector pos) {
key group_id = llList2Key(llGetParcelDetails(pos, [PARCEL_DETAILS_GROUP]), 0); integer parcel_flags = llGetParcelFlags(pos); if(parcel_flags & PARCEL_FLAG_ALLOW_CREATE_OBJECTS) { return TRUE; } else if((parcel_flags & PARCEL_FLAG_ALLOW_CREATE_GROUP_OBJECTS) && llSameGroup(group_id)) { return TRUE; } else { return FALSE; }
} </lsl>
Notes
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.
See Also
Functions
• | llDetectedGroup | – | Used in conjunction with detection events |