# llGetParcelPrimCount

*LSL function*

```lsl
integer integer llGetParcelPrimCount(vector pos, integer category, integer sim_wide);
```

- `vector pos`: Position vector in region coordinates (the Z component is ignored).
- `integer category`: PARCEL_COUNT_* category flag.
- `integer sim_wide`: Boolean. If TRUE, searches all parcels in the region owned by the targeted parcel's owner; if FALSE, searches only the specified parcel.

- Returns: `integer`
- Energy: 10

Returns an integer representing the total land impact of objects on the parcel at pos in the specified category. If sim_wide is TRUE, returns combined usage for all regional parcels owned by the parcel owner; if FALSE, returns usage for only the specified parcel.

Returns an [integer](https://wiki.secondlife.com/wiki/integer) that is the total [land impact](http://community.secondlife.com/t5/English-Knowledge-Base/Calculating-land-impact/ta-p/974163) of objects on the parcel at **pos** of the given **category**

```lsl title="How to use" frame="terminal"
integer result = llGetParcelPrimCount(ZERO_VECTOR, 0, 0);
```

## Specification

If **sim_wide** is...

- then the return is the object land impact used of the category requested on the parcel specified.

| Category |  | Description |
| --- | --- | --- |
| [PARCEL_COUNT_TOTAL](/constants/PARCEL_COUNT_TOTAL/) | 0 | All objects on the parcel(s). Does not include temp on rez objects. |
| [PARCEL_COUNT_OWNER](/constants/PARCEL_COUNT_OWNER/) | 1 | Objects owned by the parcel owner. |
| [PARCEL_COUNT_GROUP](/constants/PARCEL_COUNT_GROUP/) | 2 | Objects not owned by the owner, but set to or owned by the group of the parcel. |
| [PARCEL_COUNT_OTHER](/constants/PARCEL_COUNT_OTHER/) | 3 | Objects not set to group or owned by the owner. |
| [PARCEL_COUNT_SELECTED](/constants/PARCEL_COUNT_SELECTED/) | 4 | All objects selected or sat on. |
| [PARCEL_COUNT_TEMP](/constants/PARCEL_COUNT_TEMP/) | 5 | All temp on rez objects. |

## Caveats

- Temp mesh is not included in totals for [PARCEL_COUNT_TEMP](/constants/PARCEL_COUNT_TEMP/)

## Examples

<details open>
<summary>Example 1</summary>

```lsl collapse={1-5, 11-33}
//  gives prim usage information when touched

string primCountThisParcel(integer flag)
{
    vector currentPosition = llGetPos();

    return
        (string)llGetParcelPrimCount(currentPosition, flag, FALSE);
}

default
{
    touch_start(integer total_number)
    {
        llSay(PUBLIC_CHANNEL,
            "The total land impact of objects on this parcel is " + primCountThisParcel(PARCEL_COUNT_TOTAL) + ".");

        llSay(PUBLIC_CHANNEL,
            primCountThisParcel(PARCEL_COUNT_OWNER) + " LI for objects owned by the parcel owner.");

        llSay(PUBLIC_CHANNEL,
            primCountThisParcel(PARCEL_COUNT_GROUP) + " LI for objects set to or owned by the parcel's group.");

        llSay(PUBLIC_CHANNEL,
            primCountThisParcel(PARCEL_COUNT_OTHER) + " LI for objects not set to the parcel group or owned by the parcel owner.");

        llSay(PUBLIC_CHANNEL,
            primCountThisParcel(PARCEL_COUNT_SELECTED) + " LI for selected objects.");

        llSay(PUBLIC_CHANNEL,
            primCountThisParcel(PARCEL_COUNT_TEMP) + " LI for temp-on-rez objects.");
    }
}
```

</details>

<details>
<summary>Example 2</summary>

```lsl collapse={1-46, 52-72}
//Sim-wide scanner to count prim use in each parcel
list gPrclID;
integer gTotPrims;
float gX;
float gY;
string gObjName;
integer gNUM;

default
{
    state_entry()
    {
        gObjName = llGetObjectName();
        gPrclID = [];
        gTotPrims = 0;
        // Begin scanning at the SW <0.0,0.0,0.0> corner of the sim
        gX = 4.0;
        gY = 4.0;
    }

    on_rez(integer start)
    {
        llSetPos(llGetPos() + <0.0,0.0,0.5>);
        llSetText("Touch to start scan",<1.0,1.0,0.0>,1.0);
    }

    touch_start(integer total_number)
    {
        llSetText("Scanning ....",<1.0,1.0,0.0>,1.0);
        gNUM = 0;
        llRegionSayTo(llGetOwner(),0,"Scan started on " + llGetRegionName());
        llSetTimerEvent(0.1);
    }

    timer()
    {
        //Grab the parcel's ID and name at position <gX, gY, 100.0>
        list parcel = llGetParcelDetails(<gX,gY,100.0>,[PARCEL_DETAILS_ID,PARCEL_DETAILS_NAME]);
        key temp = llList2Key(parcel,0);
        string parcel_name = llList2String(parcel,1);
        if (parcel_name == "")
        {
            parcel_name = "(no name)";
        }
        if (!~llListFindList(gPrclID,[temp]))   //Scan at this location if this parcel was not scanned earlier
        {
            ++gNUM;
            llSetObjectName((string)gNUM);
            integer Count = llGetParcelPrimCount(<gX,gY,100>,PARCEL_COUNT_TOTAL,FALSE); //Do not include other parcels owned by llGetOwner()
            gTotPrims += Count;
            llRegionSayTo(llGetOwner(),0, "/me "+ parcel_name + " @ <"+(string)gX+","+(string)gY+",Z>  = " + (string)Count);
            gPrclID += [temp];  //Add this parcel to the "previously scanned" list
        }
        // Increment X and Y in successive scans to look at the entire sim in 8m square blocks
        if (gX < 256.0)
        {
            gX +=8.0;
        }
        if (gX > 256.0)
        {
            gY += 8.0;
            gX = 4.0;
        }
        if (gY > 256.0) // Reached NE corner
        {
            llSetObjectName(gObjName);
            llRegionSayTo(llGetOwner(),0,"Scan finished.  Total land impact = " + (string)gTotPrims + " in " + (string)llGetListLength(gPrclID) + " parcels (not counting temp rez prims).");
            llSetText("Touch to start scan",<1.0,1.0,0.0>,1.0);
            llResetScript();
        }
    }
}
```

</details>

## See also

### Functions

- [llGetParcelMaxPrims](/functions/llGetParcelMaxPrims/)

### Articles

For a detailed explanation on how the land impact is calculated, see also [Jenni Darkwatch's post](https://community.secondlife.com/forums/topic/83294-prims-prim-equivalent-land-impact-a-too-long-guide/) from late 2011.

---

*Source: [LlGetParcelPrimCount](https://wiki.secondlife.com/wiki/LlGetParcelPrimCount) on the Second Life Wiki. Content from the Second Life Wiki articles LlGetParcelPrimCount (revision 1214699, 2023-10-03), Template:LSL Constants/Parcel Prim Count (revision 1185602, 2013-12-24), Template:LSL Function/position (revision 1169387, 2012-06-18) and Template:LSL Function/boolean (revision 1185613, 2013-12-24), CC BY-SA 3.0.*

---

From lsl.dev: https://lsl.dev/functions/llGetParcelPrimCount/
