lsl V1.1

V1.1

Visitor Logger Scanner.lsl
//v1.1
//Settings
float SCAN_DELAY = 60; //seconds
integer DEBUG = TRUE;
string location = "";
float SCAN_RANGE = 32;

//Constants
string baseURL = "https://docs.google.com/forms/d/e/<GOOGLE_SHEET_ID>/formResponse?";
key reqid = NULL_KEY;

//Functions
string getURL(string location, key detectedUser) {
    return baseURL + "entry.1716462376=" +llEscapeURL(location) +"&entry.1620137166="+llEscapeURL(detectedUser)+"&entry.1704504228="+llEscapeURL(llKey2Name(detectedUser));
}

debugSay(string msg) {
    if(DEBUG) {
        llOwnerSay(msg);
    }
}

list avatarsInRegion = [];

send_data()
{
    key avatar = llList2Key( avatarsInRegion, 0);
    avatarsInRegion = llDeleteSubList(avatarsInRegion, 0, 1);

    string url = getURL(location, avatar);
    debugSay("URL IS: "+url);

    reqid = llHTTPRequest(url, [], "");
    if (reqid == NULL_KEY) //we hit the throttle
    {
        llSleep(45); //to clear the throttle wait at leat 40 seconds.
        send_data();
    }
}

start_scanner() {
    llSensorRemove();
    llSensorRepeat( "", "", AGENT, SCAN_RANGE, TWO_PI, SCAN_DELAY );
}


default {

    on_rez(integer start_param)
    {
        llResetScript();
    }
    state_entry()
    {
        location = llGetObjectDesc();
        if (llStringLength(location) == 0 || location == "(No Description)") {
            llOwnerSay("Description is Empty, Halting. Set Description and reset script");
            return;
        }
        llOwnerSay("Starting Logging data for location: "+location);
        start_scanner();
        
    }
    sensor( integer number_detected )
    {
        debugSay("Detected: "+(string)number_detected);
        
        integer i;
        for( i = 0; i < number_detected; i++ )
        {
            key detected_key = llDetectedKey( i );
            debugSay("Detected: "+(string)i +"  "+(string)detected_key);
            avatarsInRegion += (string)detected_key;
        }
        llSensorRemove();
        debugSay(llDumpList2String(avatarsInRegion, ","));
        send_data();
        
    }
    http_response(key request_id, integer status, list metadata, string body)
    {
        if (reqid == request_id)
        {
            reqid = NULL_KEY;
            debugSay("Reply: "+(string)status);
            llSleep(1); //seconds
            if (llGetListLength(avatarsInRegion) != 0) {
                send_data();
            } else {
                debugSay("Timer Set, all data sent");
                start_scanner();
            }
        }
        else
        {
            debugSay("Invalid Key");
        }
    }
}
VisitorLogger.lsl
//v1.1
//Settings
float SCAN_DELAY = 60; //seconds
integer DEBUG = FALSE;
string location = "";

//Constants
string baseURL = "https://docs.google.com/forms/d/e/<GOOGLE_SHEET_ID>/formResponse?";
key reqid = NULL_KEY;

//Functions
string getURL(string location, key detectedUser) {
    return baseURL + "entry.1716462376=" +location +"&entry.1620137166="+llEscapeURL(detectedUser)+"&entry.1704504228="+llEscapeURL(llKey2Name(detectedUser));
}

debugSay(string msg) {
    if(DEBUG) {
        llOwnerSay(msg);
    }
}

list avatarsInRegion = [];

send_data()
{
    llSetTimerEvent(0);

    //the first time called fill the array
    if (llGetListLength(avatarsInRegion) == 0) {
        avatarsInRegion = llGetAgentList(AGENT_LIST_REGION, []);
    }
    key avatar = llList2Key( avatarsInRegion, 0);
    avatarsInRegion = llDeleteSubList(avatarsInRegion, 0, 1);

    string url = getURL(location, avatar);
    // debugSay("URL IS: "+url);
    reqid = llHTTPRequest(url, [], "");
    if (reqid == NULL_KEY) //we hit the throttle
    {
        llSleep(45); //to clear the throttle wait at leat 40 seconds.
        send_data();
    }
}


default {

    on_rez(integer start_param)
    {
        llResetScript();
    }
    state_entry()
    {
        location = llGetObjectDesc();
        if (llStringLength(location) == 0 || location == "(No Description)") {
            llOwnerSay("Description is Empty, Halting. Set Description and reset script");
            return;
        }
        llOwnerSay("Starting");
        send_data(); //this will also start the timer.
    }
    timer()
    {
        send_data();
    }
    http_response(key request_id, integer status, list metadata, string body)
    {
        if (reqid == request_id)
        {
            reqid = NULL_KEY;
            debugSay("Reply: "+(string)status);
            llSleep(1); //seconds
            if (llGetListLength(avatarsInRegion) != 0) {
                send_data();
            } else {
                debugSay("Timer Set, all data sent");
                llSetTimerEvent(SCAN_DELAY);
            }
        }
        else
        {
            debugSay("Invalid Key");
        }
    }
}

lsl Ann Enigma的Notecard选择器

Ann Enigma的Notecard选择器

notecard_selector.lsl
//  Notecard Selector
//  by Ann Enigma
//  This script presents users with a list of notecards in a dialog box, and allows them to select one
//  Note: The names of the notecards must be less than 24 characters long

// This script is licenced under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License
// http://creativecommons.org/licenses/by-nc-sa/3.0/us/

// configurable options
string message = "Which notecard would you like to read?"; // the message on the dialog box
integer command_channel = 616; // the channel on which to listen for commands (you probably won't need to change this)

// the script
list notecards;

default
{
     state_entry() 
     {
          integer i = 0;

          // read the title of each notecard into a list
          for(i=0;i<llGetInventoryNumber(INVENTORY_NOTECARD);i++) {
               notecards = (notecards=[]) + notecards + [llGetInventoryName(INVENTORY_NOTECARD,i)];
          }

          llListen(command_channel, "", "", ""); // listen for a dialog button press

     }

     touch_start(integer total_number)
     {
          llDialog(llDetectedKey(0), message, notecards, command_channel); // present the dialog
     }

     listen(integer channel, string name, key id, string message) 
     {
          if (llListFindList(notecards, (list)message) != -1) // this is a valid notecard
          { 
               llGiveInventory(id, message); // give the user the notecard
          }
     }

     changed(integer changed_bitfield) 
     {
          // if the object's inventory changes, reset the script
          if (changed_bitfield | CHANGED_INVENTORY) 
          {
               llResetScript();
          }
     }
}