Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //access by group, by owner, everyone, selected users
- //message
- integer chan;
- list adminList;
- float scanFrequency;
- float spamTime;
- integer scanSensor = FALSE;
- integer IMAdmin = TRUE;
- key user;
- string menu1Text = "Azn's Super Scan 1b \n Select an Option";
- list menu1 = ["Access", "Scan Type", "Scan Frequency", "Spam Time"];
- /*//( v7-D Advanced Avatar Greeter v1.4.2 Annotated )//*/
- /*//-- Notes:
- This script attempts (within the limits of LSL) To only greet avatars once per timeout period
- The timeout period start when they leave, and favors not re-greeting frequent visitors (perceived as spam)
- Remove Lines marked **Dynamic Memory Limitation Section** if you are sure of the max avs you want to store
- Remove Lines marked **Timeout Culling Section** if you want to greet the same avatar only once
- --//*/
- /*//-- Core Variables --//*/
- list getListOfAvatarKeys; //-- List Of Avatars Keys Greeted
- list listOfSingleAvatarKeysWhileSensing; //-- List Of Single Av Key Checked During Sensor Processing
- integer indexOfCheckedItemInList; //-- Index Of Checked Item In List (reused)
- integer maximumNumberOfNamesToStore = 500; //-- Maximum Number of Names To Store (ignored if Dynamic Memory used)
- /*//-- Next Line: **Dynamic Memory Limitation Section** --//*/
- integer SafetyReserveBytesOfMemory = 1024; //-- Memory bytes to preserve for safety (Needs to be > ~768)
- /*//-- Start **Timeout Culling Section** --//*/
- integer secondsSinceAvatarLastVisit = 3600; //18800 = 30min //172800; //-- Number Of Seconds since last visit to store Av
- integer storeCurrentTimeOfSensing; //-- Integer To Store Current Time During Sensor Processing
- list listOfMostRecentAvatarVisitTimes; //-- List Of Most Recent Times Avs Were Greeted At
- list listToStoreCalculatedTimeoutDuringSensorProcessing; //-- List To Store Calculated Timeout During Sensor Processing
- /*//-- End **Timeout Culling Section** --//*/
- default{
- state_entry(){
- chan = llGetUnixTime();
- adminList += llGetOwner();
- llOwnerSay(llDumpList2String(adminList, ","));
- //-- Next Line: **Dynamic Memory Limitation Section**
- maximumNumberOfNamesToStore = SafetyReserveBytesOfMemory; //--< **Dynamic Memory Limitation Section**
- llSensor( "", "", AGENT, 32.0, PI ); //-- Pre-Fire Sensor for immediate results
- llSetTimerEvent( 30.0 ); //-- How often (in seconds) to look for new people
- }
- touch_start(integer num_detected)
- {
- user = llDetectedKey(0);
- if(~llListFindList(adminList, [user]))//if the toucher is on the admin list
- {//it exists
- llDialog(user, menu1Text, menu1, chan);
- // This works because ~(-1) produces 0, but ~ of any other value produces non-zero and causes the 'if' to succeed // So any return value (including 0) that corresponds to a found item, will make the condition succeed // It saves bytecode and is faster then doing != -1
- // This is a bitwise NOT (~) not a negation (-)
- }
- }
- listen(integer channel, string name, key ID, string message)
- {
- if(message == "Access")
- {
- state accessList;
- }
- else if(message == "Scan Type")
- {
- llDialog(ID, "Choose Scan Type:", ["Sensor", "Parcel"], chan);
- }
- else if(message == "Scan Frequency")
- {
- llDialog(user, "Choose Scan Frequency:", ["1 Second", "5 Seconds", "10 Seconds", "15 Seconds", "30 Seconds", "1 Minute", "5 Minutes", "10 Minutes", "30 Minutes", "1 Hour", "2 Hours", "4 Hours", "8 Hours", "12 Hours", "24 Hours"], chan);
- }
- else if(message == "Spam Time")
- {
- llDialog(user, "Choose greet time since last visit:", ["Every Visit", "1 Hour", "2 Hours", "4 Hours", "8 Hours", "12 Hours", "1 Day", "2 Days", "3 Days", "4 Days", "5 Days", "6 Days", "1 Week", "2 Weeks", "1 Month"], chan);
- }
- }
- timer(){
- llSensor( "", "", AGENT, 32.0, PI ); //-- Look for avatars
- }
- sensor( integer vIntSns ){ //-- Get "now" and "timeout" once, saving timeout as a list for ease of use
- listToStoreCalculatedTimeoutDuringSensorProcessing = (list)(secondsSinceAvatarLastVisit + (storeCurrentTimeOfSensing = llGetUnixTime())); //--< **Timeout Culling Section**
- do{ //-- Have we greeted these av's in our time frame?
- if (~(indexOfCheckedItemInList = llListFindList( getListOfAvatarKeys, (listOfSingleAvatarKeysWhileSensing = (list)llDetectedKey( --vIntSns )) ))){
- getListOfAvatarKeys = listOfSingleAvatarKeysWhileSensing + llDeleteSubList( getListOfAvatarKeys, indexOfCheckedItemInList, indexOfCheckedItemInList ); //-- prevents spamming frequent visitors
- listOfMostRecentAvatarVisitTimes = listToStoreCalculatedTimeoutDuringSensorProcessing + llDeleteSubList( listOfMostRecentAvatarVisitTimes, indexOfCheckedItemInList, indexOfCheckedItemInList ); //--< **Timeout Culling Section**
- }else{ //-- New Av, greet and save
- llInstantMessage("a9780071-adcf-49f4-a862-a3f48bfd43d7", llDetectedName(vIntSns) + " is at Azn's");
- //[ " + (string)id + " ]");
- llSay(0, "Hello " + llDetectedName( vIntSns ) + ". \nWelcome to Azn's" );
- getListOfAvatarKeys = llList2List( listOfSingleAvatarKeysWhileSensing + getListOfAvatarKeys, 0, maximumNumberOfNamesToStore );
- listOfMostRecentAvatarVisitTimes = llList2List( listToStoreCalculatedTimeoutDuringSensorProcessing + listOfMostRecentAvatarVisitTimes, 0, maximumNumberOfNamesToStore ); //--< **Timeout Culling Section**
- }
- }while (vIntSns);
- /*//-- Start **Dynamic Memory Limitation Section** --//*/
- if (SafetyReserveBytesOfMemory == maximumNumberOfNamesToStore){ //-- check value to see if we need to do this, should happen 1 time only
- if (SafetyReserveBytesOfMemory > llGetFreeMemory()){ //-- are we running out of free space?
- maximumNumberOfNamesToStore = ~([] != getListOfAvatarKeys); //-- Limit list to current_length - 1 to prevent stack/heap collision
- }
- } /*//-- End **Dynamic Memory Limitation Section** --//*/
- /*//-- Start **Timeout Culling Section** --//*/
- if (indexOfCheckedItemInList = (listOfMostRecentAvatarVisitTimes != [])){
- if (storeCurrentTimeOfSensing > llList2Integer( listOfMostRecentAvatarVisitTimes, --indexOfCheckedItemInList )){
- @Loop; //-- Find first index of avatars whose time since last greeting expired
- if (--indexOfCheckedItemInList){ //-- special loop structure to emulate short circuiting, while preserving vIndLst
- if (storeCurrentTimeOfSensing < llList2Integer( listOfMostRecentAvatarVisitTimes, indexOfCheckedItemInList )){
- jump Loop;
- }
- } //-- Next 2 Lines: Remove Avs whose time has expired
- getListOfAvatarKeys = llList2List( (getListOfAvatarKeys = []) + getListOfAvatarKeys, 0, indexOfCheckedItemInList );
- listOfMostRecentAvatarVisitTimes = llList2List( (listOfMostRecentAvatarVisitTimes = []) + listOfMostRecentAvatarVisitTimes, 0, indexOfCheckedItemInList );
- }
- } /*//-- End **Timeout Culling Section** --//*/
- }
- }
- state accessList
- {
- touch_start(integer num_detected)
- {
- adminList = [];
- // do a 10m spherical sweep
- llSensor("", NULL_KEY, AGENT_BY_LEGACY_NAME, 10.0, PI);
- }
- sensor (integer num_detected)
- {
- string message = "Detected " + (string)num_detected + " avatar(s): " ;
- integer index;
- string name;
- while (index < num_detected)
- {
- name = llDetectedName(index++);
- adminList += name;
- message += ", " + name;
- }
- llDialog(llGetOwner(), "Choose Admin:", adminList, chan);
- llWhisper(0, message);
- }
- no_sensor()
- {
- llWhisper(0, "Nobody is near me at present.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement