-->

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.

Magic Sit Cube – 1.2

Make positioning animations easier!

##############################################################
#                                                            
#                             Magic Sit System v1.1           
#                                                             
#                            Open Source Sit Target Editor   
#                                     GPL v2.0 License       
#                                     Keep it full perms     
#                                                            
##############################################################

I. Presentation

Magic Sit System is the new easy way to configure sit targets on your chairs, beds, cars, rocks, walls, ...

No need of maths nor calculation scripts. This is the free and lagless alternative to the charmless poseballs.

II. Why you should not use poseballs

If you just want to allow residents to sit on your object, each new poseball adds an
unnecessary script to the simulator and therefore generates lag.

Each poseball adds a new prim to your object, diminishing your allowed
prims count and generating lag.

Poseballs are not natural to use, they are a convention.

Poseballs are not aesthetical.

III. How to use the Magic Kit

1) Put the script named "Magic Sit Script" into the object you want to configure
2) Rez the "Magic Sit Cube"
3) Sit on the cube (left click is enough)
4) Right-click on the cube and select "Edit" in the pizza menu that appears
5) Move and rotate the cube until your avatar is in the desired position
6) Unsit
 (more...)

llGetRegionAgentCount

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

Physics Watcher

// Sometimes when crossing sim borders, physics will spontaneously be removed from a vehicle.
// This script re-enables physics if that happens.
 
integer active = TRUE;
 
default {
    state_entry() {
        //llListen(0, "", NULL_KEY, "brake");
        //llListen(0, "", NULL_KEY, "b");
        llSetTimerEvent(1.0);
    }
 
    timer() {
        if (active) {
            if (llAvatarOnSitTarget() == llGetOwner()) {
                if (!llGetStatus(STATUS_PHYSICS)) {
                    llSleep(1.0);
                    llSetStatus(STATUS_PHYSICS, TRUE);
                }
            } else {
                active = FALSE;
                llSetTimerEvent(0.0);
            }
        } else {
            llSetTimerEvent(0.0);
            llSetStatus(STATUS_PHYSICS, FALSE);
        }
    }
 
    listen(integer channel, string name, key id, string message) {
        string myMessage = llToLower(message);
        if (id == llGetOwner()) {
            if (myMessage == "b" || myMessage == "brake") {
                if (active) {
                    active = FALSE;
                    llWhisper(0, "Emergency brake engaged! Say 'b' in chat to resume flight.");
                } else {
                    active = TRUE;
                    llSetTimerEvent(1.0);
                    llWhisper(0, "Emergency brake disengaged.");
                }
            }
        }
    }
 
    link_message(integer sender, integer num, string message, key id) {
        if (message == "throttle" || message == "engines on") {
            if (message == "throttle" && active == FALSE) {
                llWhisper(0, "Emergency brake disengaged.");
            }
            active = TRUE;
            llSetTimerEvent(1.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;
    }
}

Name To Key

//Quick hack to find and display resident's keys from the w-hat name2key database
//  Keknehv Psaltery, 5/5/06
 
key requestid;
string resident;
 
default
{
    state_entry()
    {
        llListen(1,"","","");
    }
    listen( integer chan, string name, key id, string msg )
    {
        resident = llDumpList2String(llParseString2List(msg,[" "],[])," ");
        requestid = llHTTPRequest("http://w-hat.com/name2key?name="+llDumpList2String(llParseString2List(msg,[" "],[]),"+"),[HTTP_METHOD,"GET"],"");
    }
    http_response(key request_id, integer status, list metadata, string body)
    {
        integer i;
        if (request_id == requestid)
        {
            if ( ( i = llSubStringIndex(body,resident) ) != -1 )
                llSay(0,llGetSubString(body,i,i+llStringLength(resident)+36));
            else
                llSay(0,"No resident named \""+resident+"\" found in the w-hat name2key database");
        } else
            llSay(0,(string)status+" error");
    }
}