Jump to content
You are about to reply to a thread that has been inactive for 618 days.

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

Recommended Posts

Posted

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!!
    }
}

 

Posted

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
Posted (edited)

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
  • 2 years later...
You are about to reply to a thread that has been inactive for 618 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
×
×
  • Create New...