Difference between revisions of "LlGetParcelPrimCount"

From Second Life Wiki
Jump to navigation Jump to search
m (<lsl> tag to <source>)
(30 intermediate revisions by 8 users not shown)
Line 1: Line 1:
{{LSL_Function
{{LSL_Function
|inject-2=
{{LSL_Function/position|pos|region=noZ}}
{{LSL_Function/boolean|sim_wide|non-zero=*|td=searches parcels in the region with the same owner as the targeted parcel|fd=searches only the targeted parcel|bool=*}}
|func_id=325|func_sleep=0.0|func_energy=10.0
|func_id=325|func_sleep=0.0|func_energy=10.0
|func=llGetParcelPrimCount|return_type=integer
|func=llGetParcelPrimCount|return_type=integer
|p1_type=vector|p1_name=pos
|p1_type=vector|p1_name=pos|p1_desc
|p2_type=integer|p2_name=category|p2_desc=a PARCEL_COUNT_* flag
|p2_type=integer|p2_name=category|p2_desc=a PARCEL_COUNT_* flag
|p3_type=integer|p3_name=sim_wide|p3_desc=boolean, if {{LSLG|FALSE}} returns the parcel count, otherwise sim wide
|p3_type=integer|p3_subtype=boolean|p3_name=sim_wide|p3_desc
|func_footnote
|func_footnote
|func_desc
|func_desc
|return_text=that is the number of prims on the parcel at '''pos''' of the given '''category'''
|return_text=that is the total [http://community.secondlife.com/t5/English-Knowledge-Base/Calculating-land-impact/ta-p/974163 land impact] of objects on the parcel at {{LSLP|pos}} of the given {{LSLP|category}}
|spec
|spec=If {{LSLP|sim_wide}} is...
*{{#var:TRUE}} then the return is the combined object land impact used on all parcels in the sim owned by the specified parcel's owner of the category requested.{{Footnote|handle=non-zero}}
*{{#var:FALSE}} then the return is the object land impact used of the category requested on the parcel specified.
|caveats
|caveats
|constants={{{!}}{{Prettytable}}
|constants={{LSL Constants/Parcel Prim Count}}
!colspan="2"{{!}}Category!!Meaning
|examples=
{{!}}-
<source lang="lsl2">
{{!}}{{LSLG|PARCEL_COUNT_TOTAL}}
//  gives prim usage information when touched
{{!}}0
 
{{!}}All prims on the parcel(s). Does not include temp on rez objects.
string primCountThisParcel(integer flag)
{{!}}-
{
{{!}}{{LSLG|PARCEL_COUNT_OWNER}}
    vector currentPosition = llGetPos();
{{!}}1
 
{{!}}Prims owned by the parcel owner.
    return
{{!}}-
        (string)llGetParcelPrimCount(currentPosition, flag, FALSE);
{{!}}{{LSLG|PARCEL_COUNT_GROUP}}
}
{{!}}2
 
{{!}}Prims not owned by the owner, but set to or owned by the group of the parcel.
default
{{!}}-
{
{{!}}{{LSLG|PARCEL_COUNT_OTHER}}
    touch_start(integer total_number)
{{!}}3
    {
{{!}}Prims not set to group or owned by the owner.
        llSay(PUBLIC_CHANNEL,
{{!}}-
            "The total land impact of objects on this parcel is " + primCountThisParcel(PARCEL_COUNT_TOTAL) + ".");
{{!}}{{LSLG|PARCEL_COUNT_SELECTED}}
 
{{!}}4
        llSay(PUBLIC_CHANNEL,
{{!}}All prims selected or sat on.
            primCountThisParcel(PARCEL_COUNT_OWNER) + " LI for objects owned by the parcel owner.");
{{!}}-
 
{{!}}{{LSLG|PARCEL_COUNT_TEMP}}
        llSay(PUBLIC_CHANNEL,
{{!}}5
            primCountThisParcel(PARCEL_COUNT_GROUP) + " LI for objects set to or owned by the parcel's group.");
{{!}}All temp on rez objects.
 
{{!}}}
        llSay(PUBLIC_CHANNEL,
|examples
            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.");
    }
}
</source>
<source lang="lsl2">
//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();
        }
    }
}
</source>
 
|helpers
|helpers
|also_functions
|also_functions=
{{LSL DefineRow||[[llGetParcelMaxPrims]]}}
|also_events
|also_events
|also_tests
|also_tests
Line 48: Line 138:
|sort=GetParcelPrimCount
|sort=GetParcelPrimCount
|cat1=Parcel
|cat1=Parcel
|cat2
|cat2=Parcel/Prim Count
|cat3
|cat3
|cat4
|cat4
}}
}}

Revision as of 02:39, 22 January 2015

Summary

Function: integer llGetParcelPrimCount( vector pos, integer category, integer sim_wide );

Returns an integer that is the total land impact of objects 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 object land impact used on all parcels in the sim owned by the specified parcel's owner of the category requested.[1]
  • FALSE then the return is the object land impact used of the category requested on the parcel specified.

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

Examples

//  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.");
    }
}
//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();
        }
    }
}

See Also

Functions

•  llGetParcelMaxPrims

Deep Notes

Search JIRA for related Issues

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