Command disabled: backlink

Next improvement on the decay script:


// composter script by eteam vers 2.1
//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;
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;
        //llSay(0, "part21");
        }
    else
        {
        scale2 = scale.z;
        coord = "z";
        //llSay(0, "part22");
        }
    if (coord == "y"){
        //llSay(0, "yyy");
        growthy = llFrand(0.099) + 0.9;
        }
    if (coord == "x"){
        //llSay(0, "xxx");
        growthx = llFrand(0.099) + 0.9;
        }
    if (coord == "z"){
        //llSay(0, "zzz");
        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"){
        //llSay(0, "xxx");
       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"){
        //llSay(0, "zzz");
        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()
   {


            //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.
            llSetScale(<scale.x * growthx,scale.y * growthy,scale.z * growthz>);             // Adds the amount it needs to decay along it's longest side.


//Decay Percentage
            findmin();
}
}
}





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

script2.1.txt · Last modified: 2008/01/08 18:49 by eteam
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