From Lucinda Bulloch: You can copy and paste the parts you want or all of it it does work.
//i wrote this code as part of code to grow plants, it is used to make the plants face the sun and color them from a list of colors //and adjust the food value of the plant but can easly be used for textures or all manner of thing like a sundial //Modular script will be releasing the plant code later in the year - but i found this fun to write and would like to share it with you //you can make the list as long as you like and they can all be of diff lengths - it uses float to calc the list pos so memory is the only limit float nightdivider = -0.45; // this is the lowest level Z will fall to - sl has seasons so this changes - you can work out a function for these float daydivider = 0.89; // this is the highest level Z will reach - these dividers find the correct position in the texture list integer lampoff = TRUE; list morningcolors = ; list afternooncolors = ; list eveningcolors = ; list nightcolors = ; list morningtextures = ; list afternoontextures = ; list eveningtextures = ; list nighttextures = ; integer LINK_NUMBER = LINK_SET; //if for a linked prim put its number here integer FACE = ALL_SIDES; //if for a face put its number here dotexture(list textures , integer sunposdiv) { //use the next line to test - things like the right texture names - comment out when done llSay(0,llList2String(textures,sunposdiv)); //this next line prints the texture to all faces //llSetTexture(llList2String(textures,sunposdiv),FACE); //this next line prints the texture to all faces of a linked prim //llSetLinkTexture(LINK_NUMBER,llList2String(textures,sunposdiv),FACE); //this next line use setprimparams to print the texture to all faces //llSetPrimitiveParams(); //this next line use setprimparams to print the texture to all faces of a linked prim //llSetLinkPrimitiveParams(LINK_NUMBER,); } docolors(list textures , integer sunposdiv) { //for colors list with color vectors ie llSetColor(llList2Vector(textures,sunposdiv),FACE); //this prints to a linked prim //llSetLinkColor(LINK_NUMBER,llList2Vector(textures,sunposdiv),FACE); } default { state_entry() { llSetTimerEvent(5); } timer() { llSetTimerEvent(0); //this gets the sun pos vector sunpos = llGetSunDirection(); //this bit sorts what color to use - colors can be used to tint - use this part for colors only if((sunpos.z < 0) && (sunpos.x < 0)) docolors(eveningcolors,llFloor((sunpos.z/nightdivider)*(float)llGetListLength(eveningcolors))); else if(sunpos.z < 0) docolors(nightcolors,llGetListLength(nightcolors)-llCeil((sunpos.z/nightdivider)*(float)llGetListLength(nightcolors))); else if(sunpos.x > 0) docolors(morningcolors,llFloor((sunpos.z/daydivider)*(float)llGetListLength(morningcolors))); else docolors(afternooncolors,llGetListLength(afternooncolors)-llCeil((sunpos.z/daydivider)*(float)llGetListLength(afternooncolors))); //this bit sorts what texture to use - use only this part for textures only if((sunpos.z < 0) && (sunpos.x < 0)) dotexture(eveningtextures,llFloor((sunpos.z/nightdivider)*(float)llGetListLength(eveningtextures))); else if(sunpos.z < 0) dotexture(nighttextures,llGetListLength(nighttextures)-llCeil((sunpos.z/nightdivider)*(float)llGetListLength(nighttextures))); else if(sunpos.x > 0) dotexture(morningtextures,llFloor((sunpos.z/daydivider)*(float)llGetListLength(morningtextures))); else dotexture(afternoontextures,llGetListLength(afternoontextures)-llCeil((sunpos.z/daydivider)*(float)llGetListLength(afternoontextures))); //if you wish to make it shine in the evening only - street lamp or a magic plant //format of the prim light = if((sunpos.z < 0) && (sunpos.x < 0) && (lampoff)){lampoff = FALSE; llSetPrimitiveParams();} else if((sunpos.z < 0) && (sunpos.x > 0) && (!lampoff)) {lampoff = TRUE;llSetPrimitiveParams();} llSetTimerEvent(60); } }