-->

FoxSan's 3D Tools and LSL Script Repository

Tons of LSL scripts, examples and 3D tools, free for all. There are currently 207 scripts and articles in this database.

Avatar Scanner

// Bromley College
// Linden Script Exhibition
 
// Code for Step 32 Poster
 
default
{
    touch_start(integer total_number)
    {
        llSensor("", NULL_KEY, AGENT, 96, PI);
        // Scan for all avatars (AGENT) with any name ("") and any id (NULL_KEY) within 96 metres (the maximum scan range) in all directions (PI). If any avatars are detected create an indexed list of them and raise a sensor() event.
    }
 
    sensor(integer total_number)
    // The sensor event is raised when avatars are detected. The number of detected avatars is passed to the script below in the parameter total_number.
 
    {
        llWhisper(0, (string)total_number + " avatar(s) detected" );
        // The following 'for' loop  works through the indexed list created by the llsensor() function and the outputs the name and key of each detected avatar on ch0 in turn.
 
        integer i;
        for (i = 0; i < total_number; i++)
        {
            llWhisper(0, "Avatar name: " + llDetectedName(i) + " Avatar Key: " + (string)(llDetectedKey(i)));
 
        //Given an avatar's detected object number the llDetectedName function gets the avatar's name and the llDetectedKey function gets the avatar's key.  
 
        }
    }
}
 
// End of code;

llGetRegionAgentCount

default
{
    state_entry()
    {
        llSetTimerEvent(15.0);
    }
 
    timer()
    {
        llSetText("Agents in Region: " + (string)llGetRegionAgentCount(), <1.0, 1.0, 1.0>, 1.0);
    }
}

llDetectedKey

default
{
    state_entry()
    {
        llSetText("llDetectedKey()\nTouch to detect key",<1,1,1>,1);
    }
 
    touch_start(integer total_number)
    {
      llSay(0,llDetectedKey(0));
    }
}

llDetectedName

default
{
    state_entry()
    {
        llSetText("llDetectedName()\nTouch to detect name",<1,1,1>,1);
    }
 
    touch_start(integer total_number)
    {
      llSay(0,llDetectedName(0));
    }
}

Scan Camera

//scan the room script by Ariane Brodie
 
//Dump it in any prim an attach it as a HUD;
//touching once will start a scan of the surrounding areas and
//point the camera at each person in the room
//touch to pause the scan, touch again to continue.
//when the tour is done, the camera will return to default
 
key agent;
vector pos;
vector rotz;
integer permissions;
list whoishere;
 
default
{
    state_entry()
    {
        agent=llGetOwner();
        llSetText("",<0,0,0>,0);
        whoishere = [];
        llSetCameraParams([CAMERA_ACTIVE, 0]); // 1 is active, 0 is inactive
        llReleaseCamera(agent);
    }
 
    touch_start(integer total_number)
    {
        state cam_on;
    }
}
 
state cam_on
{
    state_entry()
    {
        llSensorRepeat("","",AGENT, 90, PI,5);
    }
 
    touch_start(integer total_number)
    {
        llSensorRemove();
        state pause;
    }
 
    sensor(integer n)
    {
        integer i;
        integer j;
        rotation rot;
        list temp;
        string iSee = "";
        string newpeople = "";
        integer FoundOne = FALSE;
        for(i=0;(i<n && FoundOne == FALSE);i++)
        {
            if(llDetectedKey(i) != llGetOwner())
            {
                pos = llDetectedPos(i);
                rot = llDetectedRot(i);
                rotz = llRot2Fwd(rot);
                    rotz.x = rotz.x * 2;
                    rotz.y = rotz.y * 2;
                    rotz.z = 1;
                iSee = llDetectedName(i);
                temp = llParseString2List(iSee,[],[]);
                j = llListFindList(whoishere,temp);
                if (j < 0) {
                    whoishere = llListInsertList(temp,whoishere,0);
                    FoundOne = TRUE;
                }
                else {
                    iSee = "";
                }
            }
        }
        if(iSee != "") {
            llOwnerSay(iSee);
            llSetText(iSee,<1,1,1>,1.0);
            llRequestPermissions(llGetOwner(), PERMISSION_CONTROL_CAMERA);
        }
        else {
            llOwnerSay("no more found");
            llSetText("",<1,1,1>,1.0);
            state default;
        }
    }
 
    no_sensor()
    {
        llOwnerSay("none found");
        llSetText("",<1,1,1>,1.0);
        state default;
    }
 
    run_time_permissions(integer perm) {
        permissions = perm;
        if ((perm & PERMISSION_CONTROL_CAMERA) == PERMISSION_CONTROL_CAMERA) {
        llSetCameraParams([
        CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive
        CAMERA_BEHINDNESS_ANGLE, 0.0, // (0 to 180) degrees
        CAMERA_BEHINDNESS_LAG, 0.0, // (0 to 3) seconds
        CAMERA_DISTANCE, 0.0, // ( 0.5 to 10) meters
        CAMERA_FOCUS, pos, // region relative position
        CAMERA_FOCUS_LAG, 0.0 , // (0 to 3) seconds
        CAMERA_FOCUS_LOCKED, TRUE, // (TRUE or FALSE)
        CAMERA_FOCUS_THRESHOLD, 0.0, // (0 to 4) meters
//        CAMERA_PITCH, 80.0, // (-45 to 80) degrees
        CAMERA_POSITION, pos + rotz, // region relative position
        CAMERA_POSITION_LAG, 0.0, // (0 to 3) seconds
        CAMERA_POSITION_LOCKED, TRUE, // (TRUE or FALSE)
        CAMERA_POSITION_THRESHOLD, 0.0, // (0 to 4) meters
        CAMERA_FOCUS_OFFSET, ZERO_VECTOR // <-10,-10,-10> to <10,10,10> meters
 
        ]);
        }
    }
}
 
state pause
{
    touch_start(integer total_number)
    {
        state cam_on;
    }
}