Difference between revisions of "LlGetObjectPrimCount"

From Second Life Wiki
Jump to navigation Jump to search
m
m (Replaced <source> with <syntaxhighlight>)
 
(14 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{LSL_Function
{{LSL_Function
|inject-1={{LSL_Function/prim|prim|sim=*|}}
|func_id=323|func_sleep=0.0|func_energy=10.0
|func_id=323|func_sleep=0.0|func_energy=10.0
|func=llGetObjectPrimCount
|func=llGetObjectPrimCount
|return_type=integer|p1_type=key|p1_name=prim
|return_type=integer
|func_footnote=If '''prim''' is not the key of a prim in the sim, then the return is zero. Avatars are not counted.
|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 {{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 for an object in the sim that contains '''prim'''.
|return_text=that is the total number of prims in the object that contains {{LSLP|prim}}.
|spec
|spec
|caveats=
|caveats=
*This cannot be used to detect if an avatar is seated, use [[llGetAgentInfo]] instead.
* 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{{Footnote|handle=attachment}}. If possible use [[llGetNumberOfPrims]] instead.
|constants
|constants
|examples=
|examples=
<lsl>default{
<syntaxhighlight lang="lsl2">default
  touch_start( integer vIntTouched ){
{
    integer prims = llGetObjectPrimCount( llGetKey() );
    touch_start(integer num)
    llSay( PUBLIC_CHANNEL, "This object has "
    {
                          + (string)prims
        integer prims = llGetObjectPrimCount(llGetKey());
                          + " prims and "
        if (prims == 0)
                          + (string)(llGetNumberOfPrims() - prims)
        {
                          + " avatars.");
            // llGetObjectPrimCount returns zero for attachments.
  }
            prims = llGetNumberOfPrims();
}</lsl>
            // Avatars can't sit on attachments so this is ok.
        }
        llOwnerSay("This object has "
                    + (string)prims
                    + " prims and "
                    + (string)(llGetNumberOfPrims() - prims)
                    + " avatars.");
    }
}</syntaxhighlight>
|helpers
|helpers
|also_functions=
|also_functions=
Line 27: Line 38:
|also_events
|also_events
|also_articles
|also_articles
|notes=
|notes
[[llGetObjectPrimCount]] can be used as an alternative for [[llGetAgentSize]] for testing if a uuid that is known to be in the sim is an avatar. The big difference being the two is that [[llGetObjectPrimCount]] returns zero on avatars while [[llGetAgentSize]] returns [[ZERO_VECTOR]] on prims. These two could be used in conjunction to test if the uuid is in the sim but [[llGetBoundingBox]] mayb be a better choice.
|cat1=Object
|cat1=Object
|cat2
|cat2

Latest revision as of 10:59, 16 December 2022

Summary

Function: integer llGetObjectPrimCount( key prim );

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.
All Issues ~ Search JIRA for related Bugs

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.

Deep Notes

Search JIRA for related Issues

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 );