 
//This script periodically determines whether the avatar is sitting and rotates the tail object accordingly.
//If you want to rotate your tail, you must stop the script first, and then reset it after rotating your tail.

key      owner;
rotation defrot;

vector   sitrot   = <90,0,0>; //how many degrees on each axis the tail will rotate when sitting
integer  interval = 3; //seconds to wait in between checking if avatar is sitting or not

default
{
    state_entry()
    {
        owner = llGetOwner();
        defrot = llGetLocalRot();
        llSetTimerEvent(interval);
    }
    
    timer()
    {
        integer agentinfo = llGetAgentInfo(owner);
        
        if(agentinfo & AGENT_SITTING)
        {
            llSetRot(defrot+llEuler2Rot(sitrot*2*DEG_TO_RAD));
        }
        else
        {
            llSetRot(defrot);
        }
    }
}
