Discussion: 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;
default { state_entry() { llSetText("",<1,1,1>,1); //Clears Text above prim. } touch_start(integer num_detected) { llSetTimerEvent(15); //Starts growth in 15 seconds } timer() { //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 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 } //Reposition 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. { state_entry() { llSetText("Full Grown",<1,1,1>,1); } }
|
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
|
Original Thread
08-27-2006 16:58
_____________________
i've got nothing. 
|
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
|
08-28-2006 03:07
You should consider replacing //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 } with llSetTimerEvent(10+llFrand(50)); This ensures that timer events are between 10 and 60 seconds. Saves you two variables and way too many lines of code 
|
AudibleAura Gremminger
Registered User
Join date: 23 Jun 2006
Posts: 16
|
09-06-2006 11:32
sounds like a fun thing to do...
actual growing plants!!
there is a working garden in SL but i have forgotten the location right now... maybe someone else knows.
but, yeah... i smell a fun SL business growing here =)
|
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
|
09-06-2006 13:18
From: AudibleAura Gremminger sounds like a fun thing to do...
actual growing plants!!
there is a working garden in SL but i have forgotten the location right now... maybe someone else knows.
but, yeah... i smell a fun SL business growing here =) Anyone intersted in actual growing plants MUST VISIT SVARGA. (I hope I spelled the name right. 
|
Floog Stuart
Registered User
Join date: 28 Jun 2006
Posts: 12
|
09-06-2006 20:42
Yeah, Svarga was what inspired me to do this script. I'm trying to add a watering system and make it so it has branches that grow also. I haven't had much chance to log in to work on that though.
|
Yumi Murakami
DoIt!AttachTheEarOfACat!
Join date: 27 Sep 2005
Posts: 6,860
|
09-07-2006 07:06
From: Squirrel Wood This ensures that timer events are between 10 and 60 seconds. Saves you two variables and way too many lines of code  It may have been deliberate that delays between 15-25 seconds were more common.
|
Llauren Mandelbrot
Twenty-Four Weeks Old.
Join date: 26 Apr 2006
Posts: 665
|
Actual Growing Plants
09-07-2006 16:08
From: AudibleAura Gremminger sounds like a fun thing to do... actual growing plants!! there is a working garden in SL but i have forgotten the location right now... maybe someone else knows. but, yeah... i smell a fun SL business growing here =) Probably NOT the Garden you`re thinking of, but see the list of My Gardens in Random Ramblings of Lauren Mandelbrot.
|
Aakanaar LaSalle
Registered User
Join date: 1 Sep 2006
Posts: 132
|
09-07-2006 16:17
From: Yumi Murakami It may have been deliberate that delays between 15-25 seconds were more common. even then, I could save some lines with if (FloatValue < 10) { FloatValue += 15; } llSetTimerEvent(FloatValue);
|
Lveran Koolhaas
Registered User
Join date: 31 Dec 2004
Posts: 37
|
11-25-2006 12:57
I have growing plants in my inventory somewhere i made them a while back but havent really tried selling them yet the 2 things you have to work on is plants dont just grow up the x and y need to grow too and what do they do when they are full size. mine revert to seedlings
|
Tazmania Trefusis
Registered User
Join date: 13 Jan 2008
Posts: 85
|
04-24-2008 12:40
Im not a scripter as such but how cool this would be if combined with a fractal generator i.e. a fractal tree generator (like the one in the scripting library)
Taz
|