Jump to content

Any way to get this script to turn off and on


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

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

Recommended Posts

Ok this is what i been trying to do. I have this script that when it starts it plays a loop sound.

When you click it it shuts it off. Ho to add when i click it again to turn it back on.

What i want is for the loop sound to be playing when the script first starts and be able to turn it off and on.

If this makes any sense.

default
{
    state_entry()
    {
        llLoopSound("Spinning", 1.0);
    }
    touch_start(integer total_number)
    {
        llStopSound();// sound stops!!
    }
}

 

Link to post
Share on other sites

Add a global boolean variable ((which in LSL is really just an integer.))

Something like SoundOn = TRUE; 

Then in your touch_start event handler, check the boolean with an if statement.  If the sound is on, turn it off, and vice versa... and also, change the boolean from TRUE to  FALSE or vice versa.  ;) 

 

  • Like 1
Link to post
Share on other sites

declare a global integer and use it as a toggle with the NOT operator (!) when we touch. Example:
 

integer on;

default
{
   touch_start(integer total_number)
   {
      on = !on;  
      if (on)
          llLoopSound ...
      else // is not on (!on)
          llStopSound ...
   }
}

edit: what sandi said

Edited by Mollymews
Link to post
Share on other sites
You are about to reply to a thread that has been inactive for 226 days.

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...