Stop Animation when Touched

Expired

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);
    }
}

 

Animate on Attach

Expired

This script will animate your avatar when attached and then loop the animation.  All you need to do is change the name of the animation:

// Basic Animation / Attachment 1.0
// Catherine Omega Heavy Industries
// Heavily modified by ArchTx Edo who is fully responsible for any stupid mistakes.

string gAnimName = "express_open_mouth"; // what animation to play?

default
{
state_entry()
{
llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION); // ask the owner for permission to trigger animations
llSetTimerEvent(0.5);//I added this line.
//llStartAnimation(gAnimName);

}

on_rez(integer param)
{
llResetScript(); // reset the script as soon as it starts.
}

attach(key id)
{
integer perm = llGetPermissions();

if (id != NULL_KEY) // make sure we're actually attached.
{ 
if (! (perm & PERMISSION_TRIGGER_ANIMATION)) // remember to use bitwise operators!
{
llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION); // request permissions from the owner.
} 
}
else
{
if (perm & PERMISSION_TRIGGER_ANIMATION)
{
llStopAnimation(gAnimName); // stop the animation

}
}
}
timer()
        {
        llStopAnimation(gAnimName);
        llStartAnimation(gAnimName);
        }
}

 

Very Smooth Multi-Prim Animator

Expired

This was written by Nikkesa:

integer timer_on = 0;

list newPositions; //the list of positions to apply to the segments
list newRotations; //the list of rotations to apply to the segments

float curve_location_x = 360; //the position we are on the curve... 

float distance_between_segments = 0.1; //the distance between each segment

vector segment_size = <0.01,0.1,0.1>;
//let's start setting this **bleep**...
//Note: may want to incorporate support for different types of segments, such as if we had 3 different cones per segment...

integer number_of_segments;

list command_list;

integer i;

float counter = 0;
//setup
vector position_offset;
//part 1
float myAngle1; //the new angle thingy... used later
//part 3
rotation rotation_between; //the rotation between two segments...
vector childPos1;
vector childPos2;
vector newValue;

////////////////////////////

list position_cache;
list rotation_cache;

integer toggle_building_setting = 0;

///////////////////////////

vector childPos(integer segment_id){
    return llList2Vector( llGetLinkPrimitiveParams(segment_id, [PRIM_POSITION] ), 0 );
}

rotation childRot(integer segment_id){
    return llList2Rot(llGetLinkPrimitiveParams(segment_id, [PRIM_ROT_LOCAL]), 0);
}

vector childPosLocal(integer segment_id){
    return llList2Vector(llGetLinkPrimitiveParams(segment_id,[PRIM_POSITION]), 0) - llGetPos();
}

vector buildPositionOffset(rotation rotation_amount, vector current_position, vector axis_position, rotation base_rotation){
    //builds the position offset relative to the rotation_amount relative to the base_rotation (which should be the root prims rotation)
    return ((axis_position - current_position) - ((axis_position - current_position) * rotation_amount)) * base_rotation;
    //this will return the amount we have to move Smiley Very Happy
}

list fix_position_offsets(list myList, float limit_distance){
    //in here we want to basically scale the distance between segments so that it's always the same...
    list newList = myList;
    integer j=1;
    vector segmentPos1;
    vector segmentPos2;
    vector vector_between;
    float distance_between;
    
    for (;j  0) return 1;
    if (input <0) return -1;
    return 0;
}

/*
    OKAY, NEW PLAN 
    --------------
    We are going to pre-cache all of the positions and rotations for the animation sequence,
    and apply them over the animation sequence!
    so yeah, whatever. 
    
*/

default
{
    state_entry()
    {
        integer i = 2;
        for (;i<=llGetNumberOfPrims();i++){
            llSetLinkPrimitiveParamsFast(i,[PRIM_POS_LOCAL,<(float)(i-1) * distance_between_segments,0.0,0.0>,PRIM_ROT_LOCAL,ZERO_ROTATION, PRIM_SIZE, segment_size * i/(i+1)]);
        }
        number_of_segments = llGetNumberOfPrims() - 1;
        
        //we want to ignore any avatars,especially in case of attachment and such...
        if (number_of_segments > 1){
            while (llGetAgentSize(llGetLinkKey(number_of_segments))){
                --number_of_segments;
            }
        }
    }
    
    touch_start(integer total_number)
    {
        if (llDetectedKey(0) == llGetOwner()){
            if (timer_on == 0){
                timer_on = 1;
                llSetTimerEvent(0.04);
            } else {
                timer_on = 0;
                llSetTimerEvent(0.0);
                llResetScript();
            }
        }
        
        // let us start the building of the cache.
    }
    
    timer(){
        i = 0;
        counter++;
        
        if (toggle_building_setting == 0)
        {
            curve_location_x = curve_location_x - 12;
            if (curve_location_x <= -1) {
                curve_location_x = 360;
                llOwnerSay("Done Caching... " + (string)counter);
                counter = 0;
                toggle_building_setting = 1;
            }
            command_list = [];
            newPositions = [];
            newRotations = [];
            for (;i < number_of_segments;i++){
                
                //part 1 - set up the new positions for each segment.
                //use i+2
                
                myAngle1 = llSin(( (float)(i+2) * (PI/2 / number_of_segments) )+( curve_location_x*TWO_PI/360 )) * 0.5;
                newValue = (llGetPos() - childPos(i+2));
                //llOwnerSay((string)myAngle1);
                //newPositions += [<(float)(i+2)/(1 / distance_between_segments*0.9),0.0,0.0> + <0.0,llVecMag(newValue) * llSin(myAngle1),0.0>];
                
                newPositions += [<(float)(i+2)/(1 / distance_between_segments),0.0,0.0> + ((newValue) - (newValue * llEuler2Rot( <0.0,0.0,myAngle1> ))) + <0.0,0.0,(llCos((TWO_PI * 3/4) * ((float)1 / (float)26) * (float)i) - 1)/2>];
                
                //newPositions += [<(float)(i+2)/(distance_between_segments),0.0,0.0> + buildPositionOffset(llEuler2Rot( <0.0,myAngle1,myAngle1> ),childPos(i+2), llGetPos(),llGetRot())];
                //newPositions += [<(1/distance_between_segments)*(curve_location_x/360)*i,0.0,0.0>];
                
                //part 3 - set the rotations of the tail segments
                /*
                
                */
                
                //part 4 - build the command list for our setlinkprimparamsfast function
                
                //
                
            }
            newPositions = fix_position_offsets(newPositions, distance_between_segments);
            i = 0;
            for (;i, childPos2 - childPos1);
                newRotations += [rotation_between];
            }
            rotation_cache += newRotations;
            
        } else {
            if (counter == 30){
                counter = 0;
            }
            i = 0;
            command_list = [];
            for (;i

 

Pose Stand

Expired

//Pose Stand With A Nice Hello from You
//Second Life Linden Scripting Language Library (http://wiki.secondlife.com/wiki/Category:LSL_Library)
//Minor Addition by Chimera Firecaster (https://chimerafire.wordpress.com/) - 05/11/2010

//Use:
//  1. Rez an cylinder and create a posing stand from it.
//  2. Give the cylinder a name.  For example, if you have a store named Main Street
//     Clothing, you would name it Main Street Clothing Posing Stand.  If you are
//     making this for a friend, then use your name:  Mary Lamb Posing Stand.  The
//     name of the posing stand will appear before the greeting message.
//  3. Place this script into the "Contents" of the Object
//  4. To edit the script, double-click on its name in "Contents'
//  5. Look for "REPLACE YOUR MESSAGE..." below and replace
//     the text with your own message.
//  6. On the script editing dialog you will see "Mono"
//     Make sure it is checked. Then click on Save.

//Note: this is a FREE script.  It is given generously to the Second Life
//   community without the expectation of anything in return. It may be
//   distributed, but please do not charge for it.  That's bad form.  Besides
//   dishonoring the kindness of others will most certainly bring you bad karma.
//-----Do Not Remove Above Header

key mkLoungingAgentKey = NULL_KEY;
integer miPermissionsAcquired = FALSE;

 default
 {
 state_entry()
 {
 //overriden sit target
 //lower them a bit
 vector vLoungeTarget = <0.00, 0.00, 1.00>;

 rotation rX;
 rotation rY;
 rotation rZ;
 rotation r;

 //build rotations
 //Note: this is broken out like this to simplify the
 //        process of finding the correct sit angle.  I
 //        use the following form until I have the rotation
 //        that I want perfect, and then I simply
 //        hardcode the perfected quaterion and remove   
 //        this mess.
 //
 rX = llAxisAngle2Rot( <1 ,0,0>, 0 * DEG_TO_RAD);         //cartwheel
 rY = llAxisAngle2Rot( <0,1,0>, 0 * DEG_TO_RAD);       //sumersault
 rZ = llAxisAngle2Rot( <0,0,1>, 0 * DEG_TO_RAD);       //turn in place

 //combine rotations
 r = rX * rY * rZ;

 //override 'sit' on pie menu
 llSetSitText( "Stand" );

 //override default sit target and rotation on prim
 llSitTarget( vLoungeTarget, r );
 }

 changed(integer change)
 {
 if (change & CHANGED_LINK)
 {
 key agent = llAvatarOnSitTarget();
 if ( mkLoungingAgentKey == NULL_KEY && agent != NULL_KEY )
 {

 //changed user
 //cache new user key and request their permissions
 mkLoungingAgentKey = agent;
 llRequestPermissions(mkLoungingAgentKey,PERMISSION_TRIGGER_ANIMATION);
 }
 else if ( mkLoungingAgentKey != NULL_KEY && agent == NULL_KEY)
 {

 //user is getting up
 if ( miPermissionsAcquired )
 {

 //restore anims
 llStopAnimation("turn_180");

 }

 //reset the script to release permissions
 llResetScript();
 }
 }        
 }

 run_time_permissions(integer parm)
 {
 if(parm == PERMISSION_TRIGGER_ANIMATION)
 {
 //REPLACE YOUR MESSAGE IN THE AREAS BETWEEN QUOTES " xxxxx "  " xxxxx "
 //Watch carefully that you only replace the text between quotes
 llInstantMessage(mkLoungingAgentKey,"Hello " + llKey2Name(mkLoungingAgentKey) + ".  Thanks for using our posing stand and have a wonderful day");

 //set permission flag
 miPermissionsAcquired = TRUE;

 //cancel the sit anim
 llStopAnimation("sit");

 llStartAnimation("turn_180");
 }
 }    
}