Previous versions can be found here: vers 2.0, vers 2.1 currently there is no vers 2.2 as we added the extra 10 seconds time to vers 2.2 and released it as vers 2.3.

// composter script by eteam vers 2.3 -- Jan 2008
//mod from Growth Script
//By Floog Stuart
//Some parts of the script taken from Cid Jacob's Photosynthesis Script.
//
//Makes a prim shrink along its longest side (when the sun is out). Starts decaying when touched.
//If you edit this script please give credit to Floog Stuart and Cid Jacob and eteam.


vector direction; // States the variables used in the script
vector scale;
vector scale_stop;
float growth;
vector pos;
float repos;

// trying to determine the largest scale value

float scale1;
float scale2;
string coord;
float growthx = 1.0;
float growthy = 1.0;
float growthz = 1.0;

comparexyz() {
    vector scale = llGetScale();
    
    if (scale.x > scale.y) {
        scale1 = scale.x;
        coord = "x";
        }
    else
        { scale1 = scale.y;
            coord = "y";
        }

    if (scale1 > scale.z){
        scale2 = scale1;
        }
    else
        {
        scale2 = scale.z;
        coord = "z";
        }
    if (coord == "y"){
        growthy = llFrand(0.099) + 0.9;
        }
    if (coord == "x"){
        growthx = llFrand(0.099) + 0.9;
        }
    if (coord == "z"){
        growthz = llFrand(0.099) + 0.9;
        }
}

findmin() 
{
    if (coord == "y"){
        //llSay(0, "yyy");
float growth_percent = scale.y / .100;
llSetText("Decay " + (string)growth_percent + "%",<1,1,1>,1.0 ); //Adds the Decay Percentage above the prim.
        if ( scale.y < 0.02000 )                   // checks for minimum?
                {
                   llSetText("composted",<1,1,1>,1);      //Says that the prim is pretty much gone.
                   state fullgrown;                        //Goes to state fullgrown
                }
        }
        
    if (coord == "x"){
       float growth_percent = scale.x / .100;
llSetText("Decay " + (string)growth_percent + "%",<1,1,1>,1.0 ); //Adds the Decay Percentage above the prim.
        if ( scale.x < 0.02000 )                   // checks for minimum?
                {
                   llSetText("composted",<1,1,1>,1);      //Says that the prim is pretty much gone.
                   state fullgrown;                        //Goes to state fullgrown
                }
        }
        
    if (coord == "z"){
        float growth_percent = scale.z / .100;
llSetText("Decay " + (string)growth_percent + "%",<1,1,1>,1.0 ); //Adds the Decay Percentage above the prim.
        if ( scale.z < 0.02000 )                   // checks for minimum?
                {
                   llSetText("composted",<1,1,1>,1);      //Says that the prim is pretty much gone.
                   state fullgrown;                        //Goes to state fullgrown
                }
}
}




default
{
        state_entry()
            {
            llSetText("",<1,1,1>,1); //Clears Text above prim.
            }

    touch_start(integer num_detected)
            {
  comparexyz();
        llSetTimerEvent(15); //Starts growth in 15 seconds
            }
timer()
   {
    integer phys = llGetStatus(STATUS_PHYSICS); // physical objects don't scale
    //llSay(0, (string)phys);   
if ( phys == 1)   // change status to no physical
{
            llSetStatus(STATUS_PHYSICS,FALSE);
            }

            //Growth Timer
            float FloatValue = llFrand(1000); //Creates a random value between 1000 and 0 to be used to decide how many seconds to delay between growth
            //float FloatValue = 1000;
        if (FloatValue < 600) //if the random value is below 600 seconds
                {
            float AddedValue = FloatValue + 600; //it adds 600 more seconds
            llSetTimerEvent(AddedValue); //Sets the new growth delay to AddedValue
                }
        else //If the random Value was above 600.
            {
            llSetTimerEvent(FloatValue); //Set the new growth delay to FloatValue
            }


//Decay                
                direction = llGetSunDirection(); //Checks to make sure the sun is up.
                if ( direction.z > 0 ) //If the sun is up.
        {
            scale = llGetScale();   //Gets the size of the plant.
            scale_stop = scale;
            llSetScale(<scale.x * growthx,scale.y * growthy,scale.z * growthz>);             // Adds the amount it needs to decay along it's longest side.
if  (scale_stop == llGetScale())
{
state stuck; // no more changes happening? delete it now with a little extra time
}

//Decay Percentage
            findmin();
}
}
}





state fullgrown //state fullgrown is used to delete the decayed "trash" object.
{
        state_entry()
        {
                llSetText("composted",<1,1,1>,1);
                llDie();
        }
}

state stuck // so that something else happens if it doesn't get any smaller
{
    state_entry()
    {
    llSetText("Decay complete in 10 seconds",<1.0,0,0>,1.0 );  
    llSleep(10.0);  
    state fullgrown;
    llDie();
    }
}
script2.3.txt · Last modified: 2016/02/15 21:13 (external edit)
www.chimeric.de Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0