Sit on Animate

Written by: Headmaster
key owner;
key sitter;

string curanim;

default
{
    on_rez(integer params){llResetScript();}
    state_entry()
    {
    owner=llGetOwner();
     vector eul = <0,0,0>; //45 degrees around the z-axis, in Euler form
            eul *= DEG_TO_RAD; //convert to radians
            rotation quat = llEuler2Rot(eul); //convert to quaternion
            llSitTarget(<0,0,.2>,ZERO_ROTATION);
            llSetText("",<0,0,0>,1);
        }
            
    touch_start(integer total_number){
     
    }
    
     changed(integer change) { // something changed
     curanim=llGetInventoryName(INVENTORY_ANIMATION,0);
        if (change & CHANGED_LINK) { // and it was a link change
            llSleep(0.5); // llUnSit works better with this delay
            if (llAvatarOnSitTarget() != NULL_KEY) { // somebody is sitting on me
            sitter=llAvatarOnSitTarget();       
            llSleep(0.5);     
           llRequestPermissions(sitter, PERMISSION_TRIGGER_ANIMATION);
           llStopAnimation("sit");
           llStartAnimation(curanim);
            llSetAlpha(0,ALL_SIDES);
            }else{llStopAnimation(curanim);sitter=NULL_KEY;llSetAlpha(1,ALL_SIDES);}
        }
    }
}