-->

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.

Land Filler

//After yesterdays "ultra lag" attack, We need to fill up our parcels so that they can't rez too many items and crash the sim.
 
//The concept is simple, replicate until fail and then delete x copys.
 
//I'll leave a full permission copy at yadni's junkyard.
 
//Note: The prim names must be exact.
 
//1. Go to a far away area or up high so that this does not cause lag.
//2. Create a blank, white, "Full bright" prim and name it "Land_Fill"
//3. Place the "Land_Fill_Die" script into the prim.
//4. Take it.
//5. Create a blank, white, "Full bright" prim and name it "Land_Filler"
//6. Place the "Rez_Array" script into the prim named "Land_Filler"
//7. Place "Land_Fill" into "Land_Filler"
//8. Enter 20 into the description field of "Land_Filler" to leave space for 20 prims.
//9. Touch it twice. The first touch clears out any leftovers.
 
//------------------------
 
// Rez to fill property - (description count)
// Released into the public domain by Grumble Loudon and LaserFur Leonov
 
//Rez and then touch to either rez or kill
 
//Note, The land max is not updated imedietly, so there will be a little
// time while no objects can be rezed.
 
integer m_RezLimit = 16384; //limit the number of prims created, just in case.
 
// you could also set this if you are on rented land and don't want to go over your limit.
 
integer m_channel = 25626;
 
list    m_OwnerNames = []; //Add other owner names here for groups.
 
//**************************************************  ************************************
integer m_RezNotKill = TRUE;
integer m_RezCount = 0;
vector  m_RezPos;
integer m_RezTimeout =0;
default
{
    state_entry()
    {
        m_OwnerNames += llKey2Name(llGetOwner());  // assumes owner is online when he rezes it
        llSetStatus(STATUS_BLOCK_GRAB, TRUE); //needed if we add a touch start
    }
    //**************************************************  ***********************************
    on_rez(integer StartPram)
    {
        llResetScript();
    }//on rez
    //**************************************************  ************************************
    touch_start(integer total_number)
    {
        key DetKey = llDetectedKey(0);
        string DetName = llKey2Name(DetKey);
 
        //owner info
        list FindName;
        FindName += DetName;   //name of avitar
        if (llListFindList( m_OwnerNames,  FindName) == -1) //not an owner
        {
            m_RezNotKill = !m_RezNotKill;  //toggle
 
            if (m_RezNotKill)
            {                   //Rez
                llOwnerSay("Starting");
                m_RezCount = 1;
                m_RezPos = llGetPos();
                m_RezPos.z += 0.5;
                llRezObject("Land_Fill",m_RezPos,<0,0,0>,<0,0,0,1>,m_RezCount); //start process
                m_RezTimeout = 0;
                llSetTimerEvent(1);
            }else{
                llOwnerSay("Killing all");
                llSay(m_channel,"2147483647");  //kill all
            };//if m_RezNotKill
        };// if owner
    }// touch_start
//**************************************************  ************************************
    object_rez(key id)// it worked. So there may be more prim space left
    {
        m_RezTimeout = 0;       //reset timeout
 
        if (m_RezNotKill)     //check just in case a touch canceled the rez
        {
            ++m_RezCount;           //next number
            if (m_RezCount < m_RezLimit)
            {
                llRezObject("Land_Fill",m_RezPos,<0,0,0>,<0,0,0,1>,m_RezCount); //do it again
            };
            llSetTimerEvent(1);         //just in case a lag caused a timeout and a then a Rez
        };
    } //object_rez
      //**************************************************  ************************************
    timer()
    {
        ++m_RezTimeout;
        if (m_RezTimeout > 5)      //rez failed so parcel is full
        {
            llSay(m_channel,llGetObjectDesc());  //kill x number
            llSetTimerEvent(0);                  //kill timer
            llOwnerSay("Done");
        };
    }//timer
}//

Rezzing Sound

default
{
    state_entry()
    {
 
    }
    on_rez (integer p)
    {
        llSleep (0.5);
        llPlaySound ("e6a0e38c-dc24-a37c-aa42-dd11c891946a",1);
        llSleep (8);
    }
}

Chat Die

//This is to delete objects by chat. Place this script in an object you wish to have self delete. Say or Shout (hold ctrl while hitting enter) the word delete, and your object will self delete.
 
123//remove the 123 to be able to use this script. Just delete the numbers and make sure running in the lower left is checked and hit save.
 
//Make sure you save a copy of this script and all others in this package before removing the 123.
 
default
{
    state_entry()
    {
        llListen(0,"",llGetOwner(),"");
    }
 
    listen(integer channel, string name, key id, string m)
    {
        if (m=="delete");llDie();
    }
}

Buddy Builder Arrow

//////START SCRIPT ////// Arrow prim
 
///a little script that shapes your prim into an arrow (good for orienting front/back/etc) - not needed, but might be handy
default
{
        state_entry()
        {
                llSetPrimitiveParams([
                PRIM_TYPE, PRIM_TYPE_SPHERE, PRIM_HOLE_DEFAULT, <0.45, 0.55, 0.0>, 0.0, ZERO_VECTOR, <0.35, 0.65, 0.0> ]);
                llSetRot(ZERO_ROTATION);
                llRemoveInventory(llGetScriptName());
        }
}
////END ARROW PRIM SCRIPT

Buddy Builder Object

/////START SCRIPT //// COMPONET
 
// Builders' Buddy 1.0 (Component Pieces)
//
// by Newfie Pendragon, March 2006
//
// This script is distributed with permission that it may be used in
// any way, or may be further modified/included in resale items.
// HOWEVER, if this script is used as part of a for-sale product,
// it is required that appropriate credit be given to Newfie for
// the script (or portions used in derivatives).  That's a fair price
// in exchange for unlimited use of this script, dontcha think?
 
//INSTRUCTIONS
//(These instructions use channel 1234 in the examples, but can be
//  changed further down in the code to whatever channel you wish.)
//
// This is the *Component Piece* half of the Builders' Buddy system.
// Drop it into each 'piece' of the building.  Drop the Base Prim Script
// into the prim  that will be the container/box that will be used to
// store the building once completed.  It can be in each individual
// prim, but if you link as much as possible (and put the script in the link
// set), it'll be much more neighbourly and less strain on the sim.
//
// QUICK USE:
// - Drop this script in the Base.
// - Drop the "Component" Script in each building part.
// - Type: /12345 RECORD
// - Take all building parts into inventory
// - Drag building parts from inventory into Base Prim
// - Type /12345 BUILD
//
// OTHER COMMANDS
// - To reposition, move/rotate Base Prim Type: /12345 MOVE
// - To lock into position (removes scripts) Type: /12345 DONE
// - To delete building pieces: /12345 CLEAN
 
//////////////////////////////////////////////////////////////////////////////////////////
// Configurable Settings
integer PRIMCHAN = 12346;    //Channel used by Base Prim to talk to Component Prims;
// This must match in both scripts
 
//////////////////////////////////////////////////////////////////////////////////////////
// Runtime Variables (Dont need to change below here unless making a derivative)
vector vOffset;
rotation rRotation;
 
////////////////////////////////////////////////////////////////////////////////
string first_word(string In_String, string Token)
{
        //This routine searches for the first word in a string,
        // and returns it.  If no word boundary found, returns
        // the whole string.
        if(Token == "") Token = " ";
        integer pos = llSubStringIndex(In_String, Token);
 
        //Found it?
        if( pos >= 1 )
        return llGetSubString(In_String, 0, pos - 1);
        else
        return In_String;
}
 
////////////////////////////////////////////////////////////////////////////////
string other_words(string In_String, string Token)
{
        //This routine searches for the other-than-first words in a string,
        // and returns it.  If no word boundary found, returns
        // the an empty string.
        if( Token == "" ) Token = " ";
 
        integer pos = llSubStringIndex(In_String, Token);
 
        //Found it?
        if( pos >= 1 )
        return llGetSubString(In_String, pos + 1, llStringLength(In_String));
        else
        return "";
}
 
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
default
{
        //////////////////////////////////////////////////////////////////////////////////////////
        state_entry()
        {
                //Open up the listener
                llListen(PRIMCHAN, "", NULL_KEY, "");
        }
 
        //////////////////////////////////////////////////////////////////////////////////////////
        on_rez(integer iStart)
        {
                //Set the channel to what's specified
                if( iStart != 0 )
                {
                        PRIMCHAN = iStart;
                        state reset_listeners;
                }
        }
 
        //////////////////////////////////////////////////////////////////////////////////////////
        listen(integer iChan, string sName, key kID, string sText)
        {
                string sCmd = llToUpper(first_word(sText, " "));
 
                if( sCmd == "RECORD" )
                {
                        sText = other_words(sText, " ");
                        list lParams = llParseString2List(sText, [ "|" ], []);
                        vector vBase = (vector)llList2String(lParams, 0);
                        rotation rBase = (rotation)llList2String(lParams, 1);
 
                        vOffset = llGetPos() - vBase;
                        rRotation = llGetRot() / rBase;
                        llOwnerSay("Recorded position.");
                        return;
                }
 
                //////////////////////////////////////////////////////////////////////////////////////////
                if( sCmd == "MOVE" )
                {
                        //Calculate our destination position
                        sText = other_words(sText, " ");
                        list lParams = llParseString2List(sText, [ "|" ], []);
                        vector vBase = (vector)llList2String(lParams, 0);
                        rotation rBase = (rotation)llList2String(lParams, 1);
 
                        //Calculate our destination position
                        vector vDestPos = (vOffset * rBase) + vBase;
                        rotation rDestRot = rRotation * rBase;
 
                        llOwnerSay("Pos: " + (string)vDestPos + ", Rot: " + (string)rDestRot);
                        integer i = 0;
                        vector vLastPos = ZERO_VECTOR;
                        while( (i < 25) && (llGetPos() != vDestPos) )
                        {
                                //If we're not there....
                                if( llGetPos() != vDestPos )
                                {
                                        //We may be stuck on the ground...
                                        //Did we move at all compared to last loop?
                                        if( llGetPos() == vLastPos )
                                        {
                                                //Yep, stuck...move straight up 10m (attempt to dislodge)
                                                llSetPos(llGetPos() + <0, 0, 10.0>);
                                        } else {
                                                //Record our spot for 'stuck' detection
                                                vLastPos = llGetPos();
                                        }
                                }
                                i++;
 
                                //Try to move to destination
                                llSetPos(vDestPos);
                                llSleep(0.1);
                        }
 
                        //Set rotation
                        llSetRot(rDestRot);
                        return;
                }
 
                //////////////////////////////////////////////////////////////////////////////////////////
                if( sCmd == "DONE" )
                {
                        //We are done, remove script
                        llRemoveInventory(llGetScriptName());
                        return;
                }
 
                //////////////////////////////////////////////////////////////////////////////////////////
                if( sCmd == "CLEAN" )
                {
                        //Clean up
                        llDie();
                        return;
                }
        }
}
 
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
state reset_listeners
{
        //////////////////////////////////////////////////////////////////////////////////////////
        state_entry()
        {
                state default;
        }
}
 
///////END SCRIPT COMPONET