Skip to content

Instantly share code, notes, and snippets.

@antonyfairport
Created July 8, 2016 15:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antonyfairport/0f90adab13b321d4c0385fbb9c543240 to your computer and use it in GitHub Desktop.
Save antonyfairport/0f90adab13b321d4c0385fbb9c543240 to your computer and use it in GitHub Desktop.
//////////////////////////////////////////////////////////////////////
// Z&A Parcel Checker
// By Antony Fairport
//
// Z&A Checker - Check that parcels are always using the right
// settings.
//
// Revision history:
// ------------------------------------------------------------
//
// 2016-02-05
// Initial revision.
//////////////////////////////////////////////////////////////////////
// Constants.
string EMAIL_REPORT_TO = "report@example.com";
//////////////////////////////////////////////////////////////////////
// Globals
list g_lParcels;
//////////////////////////////////////////////////////////////////////
// Have we seen the given parcel?
integer SeenParcel( key kID )
{
return llListFindList( g_lParcels, [ kID ] ) != -1;
}
//////////////////////////////////////////////////////////////////////
// Remember the given parcel.
RememberParcel( key kID )
{
g_lParcels += kID;
}
//////////////////////////////////////////////////////////////////////
// Report on what we can find at the parcel at the given location.
string ReportOnParcelAt( integer x, integer y )
{
list lIssues;
integer iFlags = llGetParcelFlags( < x, y, 0.0 > );
if ( iFlags & PARCEL_FLAG_ALLOW_CREATE_OBJECTS )
{
lIssues += "Public Build";
}
if ( ( iFlags & PARCEL_FLAG_USE_ACCESS_GROUP ) || ( iFlags & PARCEL_FLAG_USE_ACCESS_LIST ) )
{
lIssues += "Ban lines";
}
if ( lIssues == [] )
{
lIssues += "All good";
}
return llList2CSV( lIssues );
}
//////////////////////////////////////////////////////////////////////
// Check the parcel at the given location on the region.
string CheckParcelAt( integer x, integer y )
{
// Get the ID and name of the parcel at the given spit.
list lDetails = llGetParcelDetails( < x, y, 0.0 >, [
PARCEL_DETAILS_ID, PARCEL_DETAILS_NAME
] );
// Pull out the parts.
key kID = llList2Key( lDetails, 0 );
string sName = llList2Key( lDetails, 1 );
// Bit of progress feedback.
llSetText( "Checking\n" + ( (string) x) + "," + ( (string) y ) + "\n" + sName, < 1.0, 1.0, 1.0 >, 1.0 );
// Start the report.
string sReport;
// If we've not seen that parcel yet...
if ( !SeenParcel( kID ) )
{
sReport += sName + ": " + ReportOnParcelAt( x, y ) + "\n";
RememberParcel( kID );
}
return sReport;
}
//////////////////////////////////////////////////////////////////////
// Check all parcels on a region.
string CheckParcels()
{
// Step size while walking and looking for plots.
integer PLOT_STEP = 4;
// Forget all known parcels.
g_lParcels = [];
// Start the report.
string sReport;
// Roam over the whole region, moving minimum parcel size steps.
integer x;
for ( x = 0; x < 256; x += PLOT_STEP )
{
integer y;
for ( y = 0; y < 256; y += PLOT_STEP )
{
// Check the parcel at the given spot.
sReport += CheckParcelAt( x, y );
}
}
// Ensure the progress hove text is removed.
llSetText( "", < 1.0, 1.0, 1.0 >, 1.0 );
// Return the report.
return sReport;
}
//////////////////////////////////////////////////////////////////////
// Report on all parcels.
ReportOnAllParcels( integer bForceIM )
{
string sReport = CheckParcels();
if ( ( EMAIL_REPORT_TO == "" ) || bForceIM )
{
llInstantMessage( llGetOwner(), "\n" + sReport );
}
else
{
llEmail( EMAIL_REPORT_TO, "Parcel Settings Report (" + llGetTimestamp() + ")", sReport );
}
}
//////////////////////////////////////////////////////////////////////
// Default state.
default
{
//////////////////////////////////////////////////////////////////
// State entry.
state_entry()
{
// Do a run right now.
ReportOnAllParcels( FALSE );
// Set a timer.
llSetTimerEvent( 21600.0 );
}
//////////////////////////////////////////////////////////////////
// Respond to a touch.
touch_start( integer _ )
{
// If it's the owner...
if ( llDetectedKey( 0 ) == llGetOwner() )
{
ReportOnAllParcels( TRUE );
}
}
//////////////////////////////////////////////////////////////////
// Handle a timer event.
timer()
{
ReportOnAllParcels( FALSE );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment