Difference between revisions of "LlGetObjectPrimCount"

From Second Life Wiki
Jump to navigation Jump to search
(Just check if it's zero. don't need to know why)
m (Add llGetObjectLinkKey to See Also functions)
 
(9 intermediate revisions by 5 users not shown)
Line 5: Line 5:
|return_type=integer
|return_type=integer
|p1_type=key|p1_name=prim|p1_desc
|p1_type=key|p1_name=prim|p1_desc
|func_footnote=Avatars sitting on the object are not counted{{Footnote|[[llGetNumberOfPrims]] on the other hand does count avatars sitting on the object.|llGetNumberOfPrims on the other hand does count avatars sitting on the object.}}. Zero is returned if '''prim''' {{HoverText|(1)|is not found}} is not found, {{HoverText|(2)|is part of an attachment}} is part of an attachment{{Footnote|Weather the attachment exception is a bug or a feature is unclear.|handle=attachment}}, or {{HoverText|(3)|is not a prim}} is not a prim.
|func_footnote=Avatars sitting on the object are not counted{{Footnote|[[llGetNumberOfPrims]] on the other hand does count avatars sitting on the object.|llGetNumberOfPrims on the other hand does count avatars sitting on the object.}}. Zero is returned if {{LSLP|prim}}: {{HoverText|(A)|is not found}} is not found, {{HoverText|(B)|is part of an attachment}} is part of an attachment{{Footnote|Whether the attachment exception is a bug or a feature is unclear.|handle=attachment}}, or {{HoverText|(C)|is not a prim}} is not a prim.
|func_desc
|func_desc
|return_text=that is the total number of prims in the object that contains '''prim'''.
|return_text=that is the total number of prims in the object that contains {{LSLP|prim}}.
|spec
|spec
|caveats=
|caveats=
Line 14: Line 14:
|constants
|constants
|examples=
|examples=
<lsl>default{
<syntaxhighlight lang="lsl2">default
  touch_start( integer vIntTouched ){
{
    integer prims = llGetObjectPrimCount( llGetKey() );
    touch_start(integer num)
    if( !prims ){ //does not work on attachments, but avatars can't sit on attachments.
    {
      prims = llGetNumberOfPrims();
        integer prims = llGetObjectPrimCount(llGetKey());
        if (prims == 0)
        {
            // llGetObjectPrimCount returns zero for attachments.
            prims = llGetNumberOfPrims();
            // Avatars can't sit on attachments so this is ok.
        }
        llOwnerSay("This object has "
                    + (string)prims
                    + " prims and "
                    + (string)(llGetNumberOfPrims() - prims)
                    + " avatars.");
     }
     }
    llSay( PUBLIC_CHANNEL, "This object has "
}</syntaxhighlight>
                          + (string)prims
                          + " prims and "
                          + (string)(llGetNumberOfPrims() - prims)
                          + " avatars.");
  }
}</lsl>
|helpers
|helpers
|also_functions=
|also_functions=
{{LSL DefineRow||[[llGetNumberOfPrims]]|Returns the number of prims in the current object.}}
{{LSL DefineRow||[[llGetNumberOfPrims]]|Returns the number of prims in the current object.}}
{{LSL DefineRow||[[llGetObjectLinkKey]]|Returns the key of the link in the linkset an object.}}
|also_tests
|also_tests
|also_events
|also_events

Latest revision as of 12:02, 11 October 2024

Summary

Function: integer llGetObjectPrimCount( key prim );
0.0 Forced Delay
10.0 Energy

Returns an integer that is the total number of prims in the object that contains prim.

• key prim prim UUID that is in the same region

Avatars sitting on the object are not counted[1]. Zero is returned if prim: (A) is not found, (B) is part of an attachment[2], or (C) is not a prim.

Caveats

  • This cannot be used to detect if an avatar is seated (by checking for a non-zero return), use llGetAgentInfo instead.
  • The prim count for attachments are not returned[2]. If possible use llGetNumberOfPrims instead.

Examples

default
{
    touch_start(integer num)
    {
        integer prims = llGetObjectPrimCount(llGetKey());
        if (prims == 0)
        {
            // llGetObjectPrimCount returns zero for attachments.
            prims = llGetNumberOfPrims();
            // Avatars can't sit on attachments so this is ok.
        }
        llOwnerSay("This object has "
                    + (string)prims
                    + " prims and "
                    + (string)(llGetNumberOfPrims() - prims)
                    + " avatars.");
    }
}

See Also

Functions

•  llGetNumberOfPrims Returns the number of prims in the current object.
•  llGetObjectLinkKey Returns the key of the link in the linkset an object.

Deep Notes

Footnotes

  1. ^ llGetNumberOfPrims on the other hand does count avatars sitting on the object.
  2. ^ Whether the attachment exception is a bug or a feature is unclear.

Signature

function integer llGetObjectPrimCount( key prim );