Difference between revisions of "Group Privacy"

From Second Life Wiki
Jump to navigation Jump to search
(Brush up and add to category index)
(faster loop, fixed some conditional statements and improved readability)
Line 38: Line 38:
float RANGE = 40.0;            // Scan Range (40m)
float RANGE = 40.0;            // Scan Range (40m)
float RATE = 2.0;              // Scan Rate (2 Sec)
float RATE = 2.0;              // Scan Rate (2 Sec)
vector colorWhite = <1.0, 1.0, 1.0>;


integer status;
integer status;
Line 47: Line 49:
     llSensorRemove();
     llSensorRemove();


     llSetColor(<1,1,1>, ALL_SIDES);
     llSetColor(colorWhite, ALL_SIDES);


     llSay(0, "Deactivated.");
     llSay(PUBLIC_CHANNEL, "Deactivated.");


     llSetText("Group Privacy\nOff\n\nTouch to Turn On", <1,1,1>, 1.0);
     llSetText("Group Privacy\nOff\n\nTouch to Turn On", colorWhite, (float)TRUE);
}
}


Line 62: Line 64:
     llSetColor(<1,0,0>, ALL_SIDES);
     llSetColor(<1,0,0>, ALL_SIDES);


     llSay(0, "Activated while group memebers are present.");
     llSay(PUBLIC_CHANNEL, "Activated while group memebers are present.");


     llSetText("Group Privacy\nOn\n\nTouch to Turn Off", <1,1,1>, 0.5);
     llSetText("Group Privacy\nOn\n\nTouch to Turn Off", colorWhite, 0.5);
}
}


Line 88: Line 90:
     touch_start(integer num_detected)
     touch_start(integer num_detected)
     {
     {
         if (llGetLandOwnerAt(llGetPos()) != llGetOwner())
         key id = llDetectedKey(0);
         {
        key owner = llGetOwner();
            llSay(0, "Deed device to match land group.");
         key landOwnerCurrentPosition = llGetLandOwnerAt(llGetPos());


            return;
         if (landOwnerCurrentPosition != owner)
        }
            llSay(PUBLIC_CHANNEL, "Deed device to match land group.");
 
        else
         if (llSameGroup(llDetectedKey(0)) == TRUE)
         {
         {
             if (status == FALSE)
             if (llSameGroup(id))
             {
             {
                 on();
                 if (status)
                    off();
                else
                    on();
             }
             }
             else
             else
            {
                 llSay(PUBLIC_CHANNEL, "Authorized to group members only.");
                 off();
            }
        }
 
        else
        {
            llSay(0, "Authorized to group members only.");
         }
         }
     }
     }
Line 115: Line 112:
     sensor(integer num_detected)
     sensor(integer num_detected)
     {
     {
        integer group_members;
         integer i;
         integer i;
 
         do
         integer group_members = 0;
 
        for (i = 0; i != num_detected; i++)
         {
         {
             if (llSameGroup(llDetectedKey(i)) == FALSE)
             key id = llDetectedKey(i);
            {
                boot(llDetectedKey(i));
            }


             else
             if (llSameGroup(id))
             {
             {
                 llRemoveFromLandBanList(llDetectedKey(i));
                 llRemoveFromLandBanList(id);


                 group_members++;
                 ++group_members;
             }
             }
            else
                boot(id);
         }
         }
        while (++i < num_detected);


         if (group_members == 0)
         if (!group_members)
        {
             off();
             off();
        }
     }
     }



Revision as of 11:41, 16 October 2012

Many landlords do not allow residents to have security devices that are continiously operating. This device is activated manually, and only operates so long as avatars are present. When avatars leave the vicinity, the device turns off.

Place this script into a single prim, and decorate to taste.

Requirements:

  1. Edit script range and timer frequency to suit
  2. Deed to match the land group

Operation:

  1. Insure that group members have the group tag active
  2. Touch to activate; touch to deactivate

<lsl> ////////////////////////////////////////////////////////////////////////////////////// // // Version 1.0 Release // Copyright (C) 2007, Chance Unknown // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public License // as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // //////////////////////////////////////////////////////////////////////////////////////

float duration = 60.0; // Duration of Land Ban Following the Eject (1Hr) float RANGE = 40.0; // Scan Range (40m) float RATE = 2.0; // Scan Rate (2 Sec)

vector colorWhite = <1.0, 1.0, 1.0>;

integer status;

off() {

   status = FALSE;
   llSensorRemove();
   llSetColor(colorWhite, ALL_SIDES);
   llSay(PUBLIC_CHANNEL, "Deactivated.");
   llSetText("Group Privacy\nOff\n\nTouch to Turn On", colorWhite, (float)TRUE);

}

on() {

   status = TRUE;
   llSensorRepeat("", NULL_KEY, AGENT, RANGE, PI, RATE);
   llSetColor(<1,0,0>, ALL_SIDES);
   llSay(PUBLIC_CHANNEL, "Activated while group memebers are present.");
   llSetText("Group Privacy\nOn\n\nTouch to Turn Off", colorWhite, 0.5);

}

boot(key id) {

   if (llOverMyLand(id) == TRUE)
   {
       llUnSit(id);
       llEjectFromLand(id);
       llAddToLandBanList(id, duration); // Hour of Ban
   }

}

default {

   state_entry()
   {
       off();
   }
   touch_start(integer num_detected)
   {
       key id = llDetectedKey(0);
       key owner = llGetOwner();
       key landOwnerCurrentPosition = llGetLandOwnerAt(llGetPos());
       if (landOwnerCurrentPosition != owner)
           llSay(PUBLIC_CHANNEL, "Deed device to match land group.");
       else
       {
           if (llSameGroup(id))
           {
               if (status)
                   off();
               else
                   on();
           }
           else
               llSay(PUBLIC_CHANNEL, "Authorized to group members only.");
       }
   }
   sensor(integer num_detected)
   {
       integer group_members;
       integer i;
       do
       {
           key id = llDetectedKey(i);
           if (llSameGroup(id))
           {
               llRemoveFromLandBanList(id);
               ++group_members;
           }
           else
               boot(id);
       }
       while (++i < num_detected);
       if (!group_members)
           off();
   }
   no_sensor()
   {
       off();
   }

} </lsl>