Stop Animation when Touched

Written by: Headmaster

This script stops an animation when touched:

 

//touching worn object will open close mouth

string ANIMATION = "express_open_mouth";
integer TouchSW;

default
{
    state_entry()
    {
        llSay(0, "Open Mouth Animation");
         if (!(llGetPermissions() & PERMISSION_TRIGGER_ANIMATION))
        {
            llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
        }  
    }
    
    changed(integer change)
    {
        if(change & 128)    // You'd better put the this changed() event when you use llGetOwner
        {                   // by way of precaution.
            llResetScript();
        }
    }    

    touch_start(integer total_number)
    {
        if(TouchSW == FALSE)
        {
            //llOwnerSay("Tongue Out");
            llSetTimerEvent(0.5);
        }
        else
        {
            //llOwnerSay("Tongue In");

            llSetTimerEvent(0);
        }
        TouchSW = !TouchSW;
    }
    timer()
    {
        llStopAnimation(ANIMATION);
        llStartAnimation(ANIMATION);
    }
}