Jump to content

Playing a typing sound.


Zeaig Zabelin
 Share

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

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

Recommended Posts

Hello there, I am having the hardest time trying to figure something out. I am trying to figure out if it is possible to make a script that will Play an initial sound lets say sound 1. A single time when you first start typing. And then Loop a second sound while you continue to type. And afterwards when you completely stop typing to play a 3rd final sound a single time again.

 

This is what i tried to do and i obviously have no idea what im doing as you can tell but you can get a rough idea of my thought process behind it.

 

default
{
    state_entry()
    {
       llSetTimerEvent(1);
    }
  
timer() {
                    if (llGetAgentInfo(llGetOwner()) & AGENT_TYPING) 
       
                    {
                 llPlaySound("fab88740-f506-45e1-93f9-46a8ac77303b",1.0);
                         llSleep(9.9);
                 llLoopSound("5ebbd45b-8625-60f7-cdd9-a7f5393758d8", 1.0);  
                    }
              
                else 
               {
                llStopSound();
                llPlaySound("fab88740-f506-45e1-93f9-46a8ac77303b",1.0);

                 }
        }
}

Does anyone know how to correctly make the script im trying to do? Thanks ahead so much. 

Link to comment
Share on other sites

The timer you have scripted will be triggered at 1.0 second intervals.  Unfortunately, you have subverted that by making the entire script go to sleep for 9.9 seconds almost immediately.  Then you have tried to make a sound play continuously by looping it, but the timer's one-second trigger will keep resetting that loop over and over again.  You'll have one confused timer after all of that. 

What you really want to do, as you described it, is to use a timer to check whether the owner is typing or not.  You're really only interested in two primary conditions: (1) when the typing starts and (2) when it stops.  So, set a global toggle switch that is ON when the owner is typing and OFF when s/he's not. Set a second global flag that is ON one second after the first one and OFF when the second one goes OFF.  To do that, you need one final global flag to announce a third and final condition, when that first second has passed.  The result is ...

 

timer(){    giTyping = llGetAgentInfo(llGetOwner()) & AGENT_TYPING;    if (!giTyping)    {        if (giLooping)        {            giLooping = FALSE;            giStart = FALSE;            llPlaySound("5ebbd45b-8625-60f7-cdd9-a7f5393758d8", 1.0);        }    }    else    {        if (!giLooping)        {            if (!giStart)            {                llPlaySound("fab88740-f506-45e1-93f9-46a8ac77303b",1.0);                giStart = TRUE;            }            else            {                giLooping = TRUE;                llLoopSound("5ebbd45b-8625-60f7-cdd9-a7f5393758d8", 1.0);            }        }    }}

Notice that each of the three triggering conditions only happens once but the timer keeps on ticking at its one-second intervals.  At all other times, the script is either looping the sound that was started in that last else segment or it's playing nothing at all.  Notice also that you don;t need to use llStopSound because the script can only play one sound at a time.  Your final sound effectively stops the looping one.

Just remember to make all three toggles global integer variables, because their values have to persist from one timer tick to the next.

 

       

       

  • Like 1
Link to comment
Share on other sites

If your first sound is 9.9 seconds, and you want to play the whole thing,

 you will also need a counter variable , and increment it for 10 seconds

 before you switch to the looped sound?

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3248 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...