Sit and Play Animation

// Sets a sit target and plays whatever animation is 
// stored in the contents on the prim when someone sits down.
//
// Kimm Paulino
// Written for Synonyme Toll, April 2010
 
// These numbers are totally dependent on the object containing
// the script, and possibly even the animation to be used too.
vector gPosition = <0.0, 0.0, 0.1>;
vector gRotation = <0.0, 0.0, 0.0>;  // in degrees
 
default
{
    on_rez (integer start_param)
    {
        llResetScript();
    }
 
    state_entry()
    {
        // These numbers are totally dependent on the object containing the script!
        llSitTarget (gPosition, llEuler2Rot (gRotation * DEG_TO_RAD));
    }
 
    changed (integer change)
    {
        // When someone sits on an object, the av is considered to be
        // a linked-in child prim, so the link number changes
        if (change & CHANGED_LINK)
        {
            key av = llAvatarOnSitTarget();
            if (av)
            {
                // yes so need to play the animation
                // first request permissions - results in the callback ...
                llRequestPermissions(av, PERMISSION_TRIGGER_ANIMATION);
            }
        }
    }
 
    run_time_permissions(integer perms)
    {
        // Do we have permissions to run the animations?
        // results in the timer!
        if(perms)
        {
            llSetTimerEvent(1.0);
        }
        else
        {
            llSetTimerEvent(0.0);
        }
    }
 
    timer()
    {
        key av = llAvatarOnSitTarget();
        // If the av is still sitting, play the animation stored in the prim
        if (av)
        {
            llStopAnimation("sit");
            llStartAnimation( llGetInventoryName( INVENTORY_ANIMATION, 0 ));
        }
        else
        {
            // stop playing the animations for sitting if the av
            // is no longer sitting ...
            llStopAnimation("sit_generic");
            llSetTimerEvent(0.0);
        }
    }
}

 

Flash Scratch to SL - Your Scripting Tool

Script ImageNeed to write a LSL script and don't know how to script?  I know I hate trying to get my head around LSLS when I an in a time crunch. So why not give Flash Scratch a try! Its a great tool for learning and scoding your own scripts for Second Life without having to pay someone to do it and without a crash course in LSL

A Huge thanks to John Bennet of ATLAS Institute at University of Colorado and Eric Rosenbaum at MIT for writing Scratch for SL to begin with.

Read more: Flash Scratch to SL - Your Scripting Tool