For a look at the working model, here is a SLURL for you all:
http://slurl.com/secondlife/Bishara%20Island/220/196/23
One more thing - growth is controlled by changing the value of 'Growth' and timing is controlled by changing the values of 'zee' for ripeness and 'zat' for rotteness.
I commented everything I could to prevent anyone from accidentally leaving uncommented instructions within their cut and paste action. Most comments can be removed to a notecard and the scripts cleaned up accordingly. The SLURL has a working example of the scripts shown as the Bishara Melon Tree.
Cheers,
Dumi
// Fruit Rezzing Tree Scripts
//
//Fruit script modifications and amendments by Dumisani Ah with lots of help from the SL Scripting Tips Forum.
//Based in part on the Growth Script By Floog Stuart and Cid Jacob's Photosynthesis Script.
// The initial script is to link the rezzing object to a tree branch you made so that when you rezzed the complete tree (trunk, branches, foilage and these fruit rezzing orbs) it will start the growth of the fruit immediately.
//
// The prims you should create should be at least two, one being the little fruit rezzing orb described first below, and the other being the actual fruit, a creation of yours, that you wish to 'grow' from your tree. The rest, the tree and
// foilage, you can see from my own version, how to build up. If you need help with the tree trunk prim just IM me, but my foilage sucks so best you try your own hand at it
//
// The position of the fruit rezzing orb or object or prim is important as it needs to be near enough to the end of the branch you made to look like the fruit is grwing from the tree, and far enough from the tree branch so that the growing
// fruit do not grow into the branch and spoil the look. I would recommend you place the fruit rezzer or rezzing orb just below the branch, about 0.350 below or at least 0.05 MORE than your maximm growth number you are using in the
// script. For the standard version below 0.350 is enough of a distance for the fruit to still grow and 'hang' from the branch.
//
// This fruit rezzing orb is the only part that you LINK to your tree object, and you can link as many versions as you want fruit on it. Just keep in mind that rezzing objects does impact the region's performance where you are.
//
// Once you have the rezzing orb and the fruit created and you have placed the script for each inside the content tabs of the objects, you need to copy them into your inventory or take them into inventory. Then drag one rezzing orb out
// of your inventory and place it. Open its Content tab and then drag one copy of the fruit object from your inventory into this Content tab of the fruit rezzing orb. That;s all you need to do, except to rename the versions of your
// creation in your inventory so that you don't get mixed up with which are which
//
// The rezzing action works as follows - the fruit rezzing orb 'rezzes' a new fruit and then passes it a copy of the fruit. On completion of the fruit script the fruit object rezzes a new fruit, turns physical to fall from the tree and dies.
// Fruit rezzing orb script - copy below this line
//__________________________________________________ __________
default
{
state_entry()
{
llSetText("",<1,1,1>,1);
rotation rot = llGetRot();
llRezAtRoot("fruit", llGetPos() + <0.0,0.0,0.0>, <0.0,0.0,0.0>, rot, 1000);
}
on_rez(integer start_param)
{
// Reset script when the object is rezzed
llResetScript();
}
object_rez(key child)
{
llGiveInventory(child, llKey2Name(child));
}
}
//__________________________________________________ ___________
// Copy only until above this line
// Paste this little script into a small semi transparent sphere that you place 0.350 below the end of your branch where you wish to have your fruit growing.
// Set the script to not run until you have completed your entire build.
// Growth, Color and Die script- copy below this line
//__________________________________________________ __________
//
//Makes a fruit grow on it's X and Z axis when the sun is out. Starts growth when the fruit is rezzed. Fruit ripens and rots to fall from the tree.
vector direction; //States the variables used in the script
vector scale;
float growth;
vector pos;
float zee = 0.250;
float zat = 0.270;
default
{
state_entry()
{
llSetText("",<1,1,1>,1); //Clears Text above prim.
}
on_rez(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 = 0.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 fruit.
llSetScale(<scale.x + growth,scale.y,scale.z + growth>

//Growth Percentage
// float growth_percent = scale.z / .100; //Finds the percentage it is to it's max size.
// llSetText("",<1,1,1>,1.0); //Adds the Growth Percentage above the fruit should you wish to use this. Percentage calculation in this script is only for the text comment so you may wish to comment this little section out completely as I have.
}
if(zee < scale.z) //Checks if the fruit is ripe. Again we only check Z axis as a guide to growth as the X axis would be the same value. You can use either if you wish.
{
llSetText("ripe",<1,1,1>,1); //Says that the fruit is ripe.
llSetPrimitiveParams([PRIM_COLOR, ALL_SIDES, <1.0,0.0,0.0>, 1.0]);
}
if(zat < scale.z) //Checks if the fruit is max growth. Again we only check Z axis as a guide to growth as the X axis would be the same value. You can use either if you wish.
{
llSetText("full grown ",<1,1,1>,1); //Says that the fruit is full grown.
state fullgrown; //Goes to state fullgrown shown below
}
}
}
state fullgrown //state fullgrown is used to indicate the phase where one fruit dies and regrows another in its place
{
state_entry()
{
llSetText("",<1,1,1>,1);
llSetPrimitiveParams([PRIM_COLOR, ALL_SIDES, <1.0,1.0,1.0>, 1.0]);
rotation rot = llGetRot();
llRezAtRoot("fruit", llGetPos() + <0.0,0.0,0.0>, <0.0,0.0,0.0>, rot, 1000);
}
object_rez(key child)
{
llGiveInventory(child, llKey2Name(child));
llSetPrimitiveParams([PRIM_TEMP_ON_REZ, TRUE,
PRIM_PHYSICS, TRUE]);
}
}
// NOTES TO THE USER
// All llSetText(); can be completely deleted once you are happy with the way the fruit grows. I used them only for testing as I can insert into them different statements to show progression of the script.
// Please do not remove any comments from this script and always use it with full perms in your own creations as it is in this spirit that the code was made available to all of us in SL by Floog Stuart and Cid Jacob.
// Modify and change as much as you like and experiment experiment experiment. It is how I am learning and it will certainly be as gratifying to you to succeed at something using this script as it has been for me.
//__________________________________________________ ___________
// Copy only until above this line