Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Growth Script

Floog Stuart
Registered User
Join date: 28 Jun 2006
Posts: 12
08-25-2006 11:40
A script to make a prim grow on it's Z- axis when the sun is out. And halt growth when the moon is. Also gets the percentage of it's growth from the max 10m limit. I hope you like it. My first script publically released.

//Growth Script
//By Floog Stuart
//Some parts of the script taken from Cid Jacob's Photosynthesis Script.
//Makes a prim grow on it's Z axis when the sun is out. Starts growth when touched.
//If you edit this script please give credit to Me and Cid Jacob

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

llSetText("",<1,1,1>,1); //Clears Text above prim.

touch_start(integer num_detected)
llSetTimerEvent(15); //Starts growth in 15 seconds
//Growth Timer
float FloatValue = llFrand(60); //Creates a random value between 60 and 0 to be used to decide how many seconds to delay between growth
if (FloatValue < 10) //if the random value is below 10 seconds
float AddedValue = FloatValue + 15; //it adds 15 more seconds
llSetTimerEvent(AddedValue); //Sets the new growth delay to AddedValue
else //If the random Value was above 10.
llSetTimerEvent(FloatValue); //Set the new growth delay to FloatValue

growth = llFrand(.005); //Decides how much to make it grow each time.
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,scale.y,scale.z + growth>); // Adds the amount it needs to grow to the Z axis.

//Growth Percentage
float growth_percent = scale.z / .100; //Finds the percentage it is to it's max height.
llSetText("Growth " + (string)growth_percent + "%",<1,1,1>,1.0); //Adds the Growth Percentage above the prim.

if(scale == <scale.x, scale.y, 10.00000>) //Checks if the prim is max height.
llSetText("Full Grown",<1,1,1>,1); //Says that the prim is full grown.
state fullgrown; //Goes to state fullgrown


pos = llGetPos(); // Gets current position
repos = growth / 2; //Sets the amount to reposition to half that of which it grew. To avoid the prim from sinking into the ground.
if ( direction.z > 0 )// Makes sure that it is still daytime
llSetPos(<pos.x,pos.y,pos.z + repos>);//Sets the new position.


state fullgrown //state fullgrown is used to keep the prim from repositioning when it doesnt need to anymore.
llSetText("Full Grown",<1,1,1>,1);
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Discussion Thread
08-27-2006 16:58
i've got nothing. ;)