Jump to content

need help with a script to open close mouth


YukiAbarai
 Share

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

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

Recommended Posts

Ok im trying to do a simple open close mouth script but im having a issue and i think its in the animation I don't know Im still learning LSL

So what Im trying to achieve is: anyone clicks attached object = mouth open, then Any one clicks attached object again = mouth closed 

so what I have gotten to is click = mouth open but the second click dose not close it im not sure if im missing some thing in the LSL or if it happens to be that the Animation is a looped animation but here is the script im working with if anyone can help out

Script:

string animation;

default
{
    state_entry()
    {        
        animation = llGetInventoryName(INVENTORY_ANIMATION,0);
    }

    touch_start(integer start_param)
    {
        {     
            llRequestPermissions(llGetOwner(),PERMISSION_TRIGGER_ANIMATION);
        }
    }

    run_time_permissions(integer perm)                                  
    {
        if (perm & PERMISSION_TRIGGER_ANIMATION)
        {
            //get all animations being played on the owner of the object as keys
            list anims = llGetAnimationList( llGetOwner() );

            //if the animation is NOT being played, start it. Else, stop it
            if(llListFindList(anims, [llGetInventoryKey(animation)]) == -1)
            {
                llStartAnimation(animation);
            }
            else
            {
                llStopAnimation(animation);
            }
        }
    }    
}

Link to comment
Share on other sites

Firstly, check your logic by putting in some llOwnerSay() statements. Is the llStopAnimation() getitng called when you expect it to be?

Secondly, bento bones (face and hand movements mostly) don't move back to their default positions after an animation stops unless the animation explicitly puts them back where they belong. If you start and stop the animation manually, does your face go back to normal?

  • Like 2
Link to comment
Share on other sites

It might be easier to use a simple toggle switch.  After all, the animation is either running or it's not, and all you're really interested in is reversing its current state.  So...

touch_start(integer num)
{
     if (llGetPermissions() & PERMISSION_TRIGGER_ANIMATION)
     {
          iON = !iON;    // Assuming that you have a global inteeger variable named iON
          if (iON)
          {
               llStartAnimation(animation);
          }
          else
          {
               llStopAnimation(animation);
          }
     }
     else
     {
          llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
     }
}

  And then let your run_time_permisssions event just start the anim the first time.     

Edited by Rolig Loon
typos. as always.
  • Like 3
Link to comment
Share on other sites

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