// telegraph_attachment.lsl // 2006.07.09 by Davan Camus // // Let the object appear and play sounds when you are typing. integer gWasTyping = 0; float gStartTime = 0; float gVolume; typingStuff() { string message = ""; integer info = llGetAgentInfo(gOwner); integer isTyping = info & AGENT_TYPING; if(gWasTyping && !isTyping) { // stopped typing llStopSound(); llSetTimerEvent(1); // slow down timer again } else if(isTyping && !gWasTyping) { // started typing string soundName = llGetInventoryName(INVENTORY_SOUND,0); gVolume = 0.4; llLoopSound(soundName,gVolume); gStartTime = llGetTime(); // note how long we're typing llSetTimerEvent(0.1); // responsive timer now! } else if(isTyping && gWasTyping) { // still typing, gradually get softer, as a courtesy gVolume *= 0.9; llAdjustSoundVolume(gVolume); } gWasTyping = isTyping; } key gOwner; setup() { gOwner = llGetOwner(); llStopSound(); llSetTimerEvent(1); } default { state_entry() { setup(); } on_rez(integer start_param) { setup(); } changed(integer change) { if (change & CHANGED_LINK) setup(); } timer() { typingStuff(); } }