Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Make 2 prim object grow?

Reno Katscher
Registered User
Join date: 2 Jun 2007
Posts: 18
06-17-2007 20:35
I am using this growth script:

//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);
}
}

to make a 2 prim object grow. It is a sunflower made out of 2 prims I have linked together. Only the stem grows, the flower head does not move with the stem. Is there a way to make the head move up while the stem is growing? Does it make a difference in the order i linked the pieces? I first selected the head and then selected the stem and then linked the two together.

Thanks
Reno
Cryas Tokhes
Great Googley Moogley...
Join date: 8 Feb 2006
Posts: 124
06-18-2007 12:19
You probably have these prims linked together.. this is only affecting the parent prim. And from what you are saying, the parent prim, or the prim with the script is the stem. Try putting the script in both prims.
Reno Katscher
Registered User
Join date: 2 Jun 2007
Posts: 18
06-18-2007 13:48
If I put the script in both prims, won't it make the flower head grow in length? I need the flower head to stay the same size but move up with the stem prim....
Jake Trenchard
Registered User
Join date: 31 May 2007
Posts: 104
06-18-2007 14:05
Yes, the same script in two prims will have them both growing and not in sync with each other anyway. You need to message the flower with the amount you're growing by and have the flower move itself up with like llSetPos(llGetPos()+<0,0,growth>;)
Reno Katscher
Registered User
Join date: 2 Jun 2007
Posts: 18
06-18-2007 16:17
that sort of works, but the flower head is about half way up the stem, instead of at the top
Ed Gobo
ed44's alt
Join date: 20 Jun 2006
Posts: 220
06-18-2007 18:11
Your z position will be in the middle of the object (stem) so you will need to add half the height of the stem.