Xerev Posted July 13, 2012 Share Posted July 13, 2012 I am finding for a script that plays songs/sounds when i type. So far i made this onedefault{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 More sharing options...
Rolig Loon Posted July 13, 2012 Share Posted July 13, 2012 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 More sharing options...
Recommended Posts
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