Difference between revisions of "LlGetParcelPrimCount"

From Second Life Wiki
Jump to navigation Jump to search
Line 112: Line 112:
}
}
</lsl>
</lsl>
<lsl>
 
//For public display of who owns the prims in THIS parcel
list WhoHas = [];
key gQname;
string text;
integer count;
integer NonGroup;
default
{
    on_rez(integer startup)
    {
        llSetText("Hello?",<1.0,1.0,1.0>,1.0);
        llResetScript();
    }
   
    state_entry()
    {
        NonGroup = 0;
        count = 0;
        text = "";
        llSetText(text,<1.0,1.0,1.0>,1.0);
        WhoHas = llGetParcelPrimOwners(llGetPos());
        //Be sure to set this object to the group that owns this parcel
        key Group = llList2Key(llGetObjectDetails(llGetKey(),[OBJECT_GROUP]),0);
        integer idx = llListFindList(WhoHas,[Group]);
        if(~idx)  //Do not feed the group's UUID to the dataserver. llRequestAgentData will fail.
        {
            WhoHas = llDeleteSubList(WhoHas,idx,idx+1);
        }
        gQname = llRequestAgentData((key)llList2String(WhoHas,0),DATA_NAME);
    }
   
    dataserver(key id, string data)
    {
        if(id == gQname)
        {
            text = text + "\n" + data + " : " + llList2String(WhoHas,count + 1);
            NonGroup = NonGroup + llList2Integer(WhoHas,count+1);
            count = count + 2;
            if(count < llGetListLength(WhoHas))
            {
                gQname = llRequestAgentData(llList2Key(WhoHas,count),DATA_NAME);
            }
        }
        integer TotalPrims = llGetParcelPrimCount(llGetPos(),PARCEL_COUNT_TOTAL,FALSE); //Do not include parcels owned elsewhere by llGetOwner()
        string Pretext =  "Total prims on this Parcel = " + (string)TotalPrims;
        Pretext = Pretext + "\n Owned by group = " + (string)(TotalPrims -NonGroup);
        Pretext = Pretext + "\n Individually owned = ";
        text = Pretext + text;
        llSetText(text,<1.0,1.0,1.0>,1.0);
    }
}</lsl>
|helpers
|helpers
|also_functions=
|also_functions=

Revision as of 07:12, 8 October 2012

Summary

Function: integer llGetParcelPrimCount( vector pos, integer category, integer sim_wide );
0.0 Forced Delay
10.0 Energy

Returns an integer that is the number of prims on the parcel at pos of the given category

• vector pos position in region coordinates (z component is ignored)
• integer category a PARCEL_COUNT_* flag
• integer sim_wide boolean, TRUE[1] searches parcels in the region with the same owner as the targeted parcel, FALSE searches only the targeted parcel

Specification

If sim_wide is...

  • TRUE then the return is the combined number of prims on all parcels in the sim owned by the specified parcel's owner of the category requested.[1]
  • FALSE then the return is the number of prims of the category requested on the parcel specified.

Examples

<lsl>//gives prim usage information when touched. default {

   touch_start(integer total_number)
   {
       vector pos = llGetPos();
       llSay(0, "There are " + (string)llGetParcelPrimCount(pos, PARCEL_COUNT_TOTAL, FALSE) +
                " total prims on this parcel");
       llSay(0, (string)llGetParcelPrimCount(pos, PARCEL_COUNT_OWNER, FALSE) +
                " prims are owned by the parcel owner");
       llSay(0, (string)llGetParcelPrimCount(pos, PARCEL_COUNT_GROUP, FALSE) +
                " prims set to or owned by the parcel's group.");
       llSay(0, (string)llGetParcelPrimCount(pos, PARCEL_COUNT_OTHER, FALSE) +
                " prims that are not set to the parcel group or owned by the parcel owner");
       llSay(0, (string)llGetParcelPrimCount(pos, PARCEL_COUNT_SELECTED, FALSE) +
                " prims are selected");
       llSay(0, (string)llGetParcelPrimCount(pos, PARCEL_COUNT_TEMP, FALSE) +
                " prims are temp-on-rez");
   }

}</lsl> <lsl> //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 Prims = " + (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();
       }
   }            

}

</lsl>

See Also

Functions

•  llGetParcelMaxPrims

Deep Notes

Footnotes

  1. ^ Any value that is not zero/FALSE is treated the same as TRUE. This behavior should not be depended upon.

Signature

function integer llGetParcelPrimCount( vector pos, integer category, integer sim_wide );