Jump to content

script to control image


IvyTechEngineer
 Share

You are about to reply to a thread that has been inactive for 732 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hello

I would like to modify this script 

//Created: December 16, 2009
//Last Modified: March 17, 2010
//License: Public Domain
//Released: Wednesday, December 16, 2009

//Status: Fully Working/Production Ready
//Version: 1.0.1
//Disclaimer: These programs are distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
//            even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 

//Name: Touch Texture Switch.lsl
//Purpose: To change texture on touch
//Description: This script will change the texture on a prim when touched between the two given
//             texture and then sleep.
//Directions: Add script to prim. Change UUIDs in script and save.
//Compatible: Mono & LSL compatible
//Other items required: None
//Notes: Lagless, timerless, Originally written for EternalSailorJupiter Korobase
//     : llSetTexture has a .2 second delay, so there is automatically a .2 second delay built in.
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//global variables you may change
string texture1 = "2615e0b2-1139-0e72-d21a-74af53223838";//UUID of texture 1 (or inventory name if in inventorY)
string texture2= "b4f78391-6c54-ac5a-e3ba-8866320407ef";//UUID of texture2
float time = 0.0;//time to sleep in seconds
integer side = 1;//which side to change texture on


/////////////
//don't change below
integer currentstate;//the state its in either TRUE or FALSE
switch(string texture)
{
    llSetTexture(texture, side);
    currentstate = ~currentstate;//swith states
    llSleep(time);
}
default
{
    touch_start(integer total_number)
    {
        if(currentstate)
            switch(texture1);
        else
            switch(texture2);
    }
}

So that I can use this script to control the switching of the images

integer myswitch;

default

    state_entry()
    {
        myswitch=FALSE;
        llSetText("Control Switch", <1.0, 1.0, 1.0>, 1.0);
    }

    touch_start(integer total_number)
    {    
       if(myswitch==FALSE)
       {    
       
       //Turn Light Bulb ON
     
       llMessageLinked(LINK_ALL_CHILDREN, 0, "start", NULL_KEY);
       llSetColor(<0.0, 1.0, 0.0>, ALL_SIDES);  
       myswitch=TRUE;
       
       }
       else
      {
          
      //Turn Light Bulb Off
          
      llMessageLinked(LINK_ALL_CHILDREN, 0, "stop", NULL_KEY);
      llSetColor(<1.0, 0.0, 0.0>, ALL_SIDES);  
      myswitch=FALSE;    
      
      }
    
    }
}

Current this script is turning on an off a light and turning on and off of the rotation of a object. 

Suggestions?

Thanks

Link to comment
Share on other sites

Those two scripts are both examples of a simple toggle switch, like the wall switch that you use to turn a light on or off in your RL house.  The logic used to change from OFF to ON (or the reverse) is exactly the same in each: an integer variable (myswitch or currentstate) is flipped from FALSE to TRUE (or from 0 to 1).  Just as in your house, ON can activate a signal to turn on a light or an appliance, display an image, start a sound, make something move.  OFF reverses it. So, when you write your script, you keep the basic structure of the switch and add whatever statements you need to have happen (llSetTexture to display a particular texture, llSetColor to display a particular color, ... or whatever). 

  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 732 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...