Rizzy Khaos Posted August 9, 2016 Share Posted August 9, 2016 Was looking through the forum and couldn't find any help on this. Can someone help me out with a script that plays an animation when I type? Link to comment Share on other sites More sharing options...
Rolig Loon Posted August 9, 2016 Share Posted August 9, 2016 When you write a script like that, you'll want to run a fast timer (0.2 to 0.5 seconds) and check llGetAgentInfo each time it fires. Specifically, ask whether AGENT_TYPING is true. If so, trigger your typing animation. If not, stop it. It's actually slightly trickier than that, but not much. First of all, you can't trigger an animation without permission. In this case, you'll be running your script in a HUD, so permission is granted automatically, but you still need to ask. So, be sure that you llRequestPermissions when the HUD attaches (and put if (llGetAttached()) {llRequestPermissions(llGetOwner(),PERMISSION_TRIGGER_ANIMATION;} in your state_entry event). The run_time_permissions event itself can be empty, but at least your script will have requested and been given permission. Then, to reduce excessive activity in the timer event, use a global integer variable to keep track of whether the animation is running or not. Test the value of that variable when the timer fires and only start/stop the animation when you truly need to: timer(){ integer IsTyping = llGetAgentInfo(llGetOwner()) & AGENT_TYPING; if (!gActive && IsTyping) //That is, "I'm typing but the anim isn't on yet" { llStartAnimation("my_typing_anim"); gActive = TRUE; // This is your global toggle flag } else if (gActive && !IsTyping) // That is, "I'm not typing, but the animation is still running." { llStopAnimation("my_typing_animation"); gActive = FALSE; }} That way, the timer event isn't constantly trying to turn on an animation that is already on, or turn it off when it's already off. Anything else you write is pretty stuff. That's the important innards. 1 Link to comment Share on other sites More sharing options...
Rizzy Khaos Posted August 9, 2016 Author Share Posted August 9, 2016 thank you 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