Jump to content

Play Sound When i type


Xerev
 Share

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

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

Recommended Posts

I am finding for a script that plays songs/sounds when i type. So far i made this one

default
{
state_entry()
{
llSetTimerEvent(10);
}

timer() {
if (llGetAgentInfo(llGetOwner()) & AGENT_TYPING)

{
llLoopSound("A5", 0.2);
}

else
{
llStopSound();
}
}
}

But the problem is it stil plays the song even when i stop typing. Its kinda buggy. Hope someone else have better script. Thanks in advance :)

 

Link to comment
Share on other sites

That's not a bad try.  The reason it keeps playing is that your timer cycle is way too long.  It's only checking once every ten seconds to see whether you are still typing.  If you start typing, the sound won't begin until ten seconds later too.  Although a fast timer adds lag to your sim, there's not a good way to avoid one in this sort of application.  Try this instead...

default{	state_entry()	{		llSetTimerEvent(0.2); // Much faster than yours	}	timer()	{		if (llGetAgentInfo(llGetOwner()) & AGENT_TYPING)		{			llPlaySound("A5", 0.2); //Play it once each time the timer triggers		}	}}

 I don't know how long your sound clip is, so I set the timer interval arbitrarily to 0.2 seconds. It doesn't make any sense to set the timer event's duration any shorter than the length of the sound clip, though.  You will just keep interrupting it each time the timer triggers, and it will still play to its end when you finally stop typing anyway. So, determine the length of your sound clip and adjust the time accordingly. 

Link to comment
Share on other sites

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

×
×
  • Create New...