Difference between revisions of "Simple Texture Changer (input list)(all prims & all sides).lsl"

From Second Life Wiki
Jump to navigation Jump to search
m (added backlink)
m (updated)
Line 1: Line 1:
Part of [[Bobbyb's texture changer]] collection  
Part of [[Bobbyb's texture changer]] collection  
<lsl>
<lsl>
//https://wiki.secondlife.com/wiki/Simple_Texture_Changer_(input_list)(all_prims_%26_all_sides).lsl
//***********************************************************************************************************
//***********************************************************************************************************
//                                                                                                          *
//                                                                                                          *
//              --Simple Texture Changer (input list)(certain prims & all sides)--                         *
//              --Simple Texture Changer (input list)(all prims & all sides)--                             *
//                                                                                                          *
//                                                                                                          *
//***********************************************************************************************************
//***********************************************************************************************************
Line 11: Line 10:
//Attribution: None required, but it is appreciated.
//Attribution: None required, but it is appreciated.
//Created: April 28, 2009
//Created: April 28, 2009
//Last Modified: November 26, 2009
//Last Modified: November 28, 2009
//Released: Saturday, November 28, 2009
//Released: Saturday, November 28, 2009
//License: Public Domain
//License: Public Domain


//Status: Fully Working/Production Ready
//Status: Fully Working/Production Ready
//Version: 1.0.5
//Version: 1.0.6


//Name: Simple Texture Changer (input list)(certain prims & all sides).lsl
//Name: Simple Texture Changer (input list)(certain prims & all sides).lsl
Line 38: Line 37:
//texture list...this list should have 2 or more textures
//texture list...this list should have 2 or more textures
list textures = [
list textures = [
"00000000-0000-0000-0000-0000f0000000",
    "00000000-0000-0000-0000-0000f0000000",
"00000000-0000-0000-0000-0000d0000000",
    "00000000-0000-0000-0000-0000d0000000",
"00000000-0000-0000-0000-0000e0000000"];//put your texture UUIDs/keys in here
    "00000000-0000-0000-0000-0000e0000000"];//put your texture UUIDs/keys in here


//Please note there is a .2 second delay between prims.
//Please note there is a .2 second delay between prims.
Line 48: Line 47:
integer random = TRUE;//whether to show the textures randomly, or in order
integer random = TRUE;//whether to show the textures randomly, or in order
integer duplicatecheck = TRUE;//if random is true, this will check to make sure the random selection is a new texture
integer duplicatecheck = TRUE;//if random is true, this will check to make sure the random selection is a new texture
 
integer atonce = FALSE;//whether to change all the prims at once, or one at a time


/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
Line 58: Line 57:
changetexture()//user fucntion to change texture;
changetexture()//user fucntion to change texture;
{
{
integer counter;
    string texture = llList2String(textures,currenttexture);
string texture = llList2String(textures,currenttexture);
    if(atonce)
do
        llSetLinkTexture(LINK_SET,texture,ALL_SIDES);
{
    else
llSetLinkTexture(counter,texture,ALL_SIDES);
    {
}while(++counter <numberofprims);
        integer counter = 1;
        do
        {
            llSetLinkTexture(counter,texture,ALL_SIDES);
        }while(++counter < (numberofprims + 1));
    }
}
}


default
default
{
{
on_rez(integer start_param)//on rez reset...probably not needed.
    on_rez(integer start_param)//on rez reset...probably not needed.
{
    {
llResetScript();
        llResetScript();
}
    }
state_entry()
    state_entry()
{
    {
llOwnerSay("Simple Texture Changer (input list)(certain prims & all sides).lsl' (Public Domain 2009)");
        llOwnerSay("Simple Texture Changer (input list)(certain prims & all sides).lsl' (Public Domain 2009)");
llOwnerSay("Because knowledge should be free.");
        llOwnerSay("Because knowledge should be free.");
numberoftextures = llGetListLength(textures);//speed hack here
        numberoftextures = llGetListLength(textures);//speed hack here
numberofprims = llGetNumberOfPrims();
        numberofprims = llGetNumberOfPrims();
//assume correct
        //assume correct
llOwnerSay("There are " + (string)numberoftextures + " pictures which I will change every "
        llOwnerSay("There are " + (string)numberoftextures + " pictures which I will change every "
+ (string)frequency + " seconds on all the sides of all the sides.");
            + (string)frequency + " seconds on all the sides of all the sides.");
llOwnerSay("My current free memory is : " + (string)llGetFreeMemory()
        llOwnerSay("My current free memory is : " + (string)llGetFreeMemory()
+ " bytes. If it is below 2500 bytes, I may not work properly.");
            + " bytes. If it is below 2500 bytes, I may not work properly.");
llSetTimerEvent(frequency);
        llSetTimerEvent(frequency);
}
    }
timer()
    timer()
{
    {
if(random)//show pics randomly
        if(random)//show pics randomly
{
        {
integer randomtexture;
            integer randomtexture;
if(duplicatecheck)//whether to make sure random doesn't repeat itself
            if(duplicatecheck)//whether to make sure random doesn't repeat itself
{
            {
do
                do
{
                {
randomtexture= llRound(llFrand(numberoftextures - 1));
                    randomtexture= llRound(llFrand(numberoftextures - 1));
//llOwnerSay("r" + (string)randomtexture);//debug
                    //llOwnerSay("r" + (string)randomtexture);//debug
}while(randomtexture == currenttexture);//make sure the random one isn't the same as the current one
                }while(randomtexture == currenttexture);//make sure the random one isn't the same as the current one
}
            }
else//no duplicate check
            else//no duplicate check
randomtexture = llRound(llFrand(numberoftextures - 1));//generate random texture number
                randomtexture = llRound(llFrand(numberoftextures - 1));//generate random texture number
currenttexture = randomtexture;//set the current one to the random one selected
            currenttexture = randomtexture;//set the current one to the random one selected
changetexture();//change the texture
            changetexture();//change the texture
//llOwnerSay("c" + (string)currenttexture);//debug
            //llOwnerSay("c" + (string)currenttexture);//debug
}
        }
else//not random, go in order
        else//not random, go in order
{
        {
++currenttexture;
            ++currenttexture;
if(currenttexture == numberoftextures)//if current texture = number of textures, reset counter
            if(currenttexture == numberoftextures)//if current texture = number of textures, reset counter
currenttexture = 0;
                currenttexture = 0;
changetexture();//change the texture
            changetexture();//change the texture
//llOwnerSay("c" + (string)currenttexture);//debug
            //llOwnerSay("c" + (string)currenttexture);//debug
}
        }
}
    }
}
}
</lsl>
</lsl>

Revision as of 14:43, 28 November 2009

Part of Bobbyb's texture changer collection <lsl> //*********************************************************************************************************** // * // --Simple Texture Changer (input list)(all prims & all sides)-- * // * //*********************************************************************************************************** // www.lsleditor.org by Alphons van der Heijden (SL: Alphons Jano) //Creator: Bobbyb30 Swashbuckler //Attribution: None required, but it is appreciated. //Created: April 28, 2009 //Last Modified: November 28, 2009 //Released: Saturday, November 28, 2009 //License: Public Domain

//Status: Fully Working/Production Ready //Version: 1.0.6

//Name: Simple Texture Changer (input list)(certain prims & all sides).lsl //Purpose: To change the texture on all linked prims on all sides based on the textures in the input list. //Technical Overview: The script finds how many textures there are in the input list, and uses a timer to change the // texture on a side based on randomness or order. It changes all sides of the certain prim to the // specified texture //Description: A simple texture changer script that changes the texture on all the sides of all linked prims in a linked // set to those in the input list. It allows for a random order, or a logical "next up" order. //Directions: Create a prim. Place the script in prim inventory. Modify the script parameters to suit your needs and // save. Reset script if you add/remove linked prims.

//Compatible: Mono & LSL compatible //Other items required: None. //Notes: Uses a timer event. Should be low lag. Commented for easier following. This will change all of the sides // of certain linked prims to the *same* texture based on the input texture list. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//Adjustable global variables...you may change these //texture list...this list should have 2 or more textures list textures = [

   "00000000-0000-0000-0000-0000f0000000",
   "00000000-0000-0000-0000-0000d0000000",
   "00000000-0000-0000-0000-0000e0000000"];//put your texture UUIDs/keys in here

//Please note there is a .2 second delay between prims. float frequency = 2.0;//how often to change the texture in seconds. Shouldn't be below 2.0

//please note that the last and first texture will be shown less frequently than those in between integer random = TRUE;//whether to show the textures randomly, or in order integer duplicatecheck = TRUE;//if random is true, this will check to make sure the random selection is a new texture integer atonce = FALSE;//whether to change all the prims at once, or one at a time

///////////////////////////////////////////////////////////// //global variables...do not change integer numberoftextures;//number of textures in inventory integer currenttexture;//inventory number of current texture integer numberofprims;//number of prims

changetexture()//user fucntion to change texture; {

   string texture = llList2String(textures,currenttexture);
   if(atonce)
       llSetLinkTexture(LINK_SET,texture,ALL_SIDES);
   else
   {
       integer counter = 1;
       do
       {
           llSetLinkTexture(counter,texture,ALL_SIDES);
       }while(++counter < (numberofprims + 1));
   }

}

default {

   on_rez(integer start_param)//on rez reset...probably not needed.
   {
       llResetScript();
   }
   state_entry()
   {
       llOwnerSay("Simple Texture Changer (input list)(certain prims & all sides).lsl' (Public Domain 2009)");
       llOwnerSay("Because knowledge should be free.");
       numberoftextures = llGetListLength(textures);//speed hack here
       numberofprims = llGetNumberOfPrims();
       //assume correct
       llOwnerSay("There are " + (string)numberoftextures + " pictures which I will change every "
           + (string)frequency + " seconds on all the sides of all the sides.");
       llOwnerSay("My current free memory is : " + (string)llGetFreeMemory()
           + " bytes. If it is below 2500 bytes, I may not work properly.");
       llSetTimerEvent(frequency);
   }
   timer()
   {
       if(random)//show pics randomly
       {
           integer randomtexture;
           if(duplicatecheck)//whether to make sure random doesn't repeat itself
           {
               do
               {
                   randomtexture= llRound(llFrand(numberoftextures - 1));
                   //llOwnerSay("r" + (string)randomtexture);//debug
               }while(randomtexture == currenttexture);//make sure the random one isn't the same as the current one
           }
           else//no duplicate check
               randomtexture = llRound(llFrand(numberoftextures - 1));//generate random texture number
           currenttexture = randomtexture;//set the current one to the random one selected
           changetexture();//change the texture
           //llOwnerSay("c" + (string)currenttexture);//debug
       }
       else//not random, go in order
       {
           ++currenttexture;
           if(currenttexture == numberoftextures)//if current texture = number of textures, reset counter
               currenttexture = 0;
           changetexture();//change the texture
           //llOwnerSay("c" + (string)currenttexture);//debug
       }
   }

} </lsl>