OSSL Script Library/OSSL Poseball

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
(Created page with "A poseball script, using OSSL functions The code contains a lot of comments, explaining what does what, and why it is there. <source lang="lsl"> // OSSL Poseball // By Fritiger...")

Revision as of 02:53, 18 March 2012

A poseball script, using OSSL functions

The code contains a lot of comments, explaining what does what, and why it is there.

// OSSL Poseball
// By Fritigern Gothly
// Written on March 18th, 2012
// Additional contributors:
// <add your name here if you made any improvements to this script>
 
vector target = <0.0, 0.0, 1.0>; // Change these values to position your avatar.
 
// =============================
// DO NOT CHANGE BELOW THIS LINE
// =============================
string anim; // Will be used for the animation name.
integer used; // Used as a flag to determine what the script should do.
key user; // This will hold the key of the user that uses the poseball
 
default
{
    state_entry()
    {
        llSitTarget(target, ZERO_ROTATION);
        anim = llGetInventoryName(INVENTORY_ANIMATION,0); // Get the first animation in the prim's inventory.
        if(anim == "") // If no animation was found...
        {
            state error; // Go and wait until the inventory has changed.
        } else { // Otherwise....
            llOwnerSay("Found animation ''"+anim+"''"); // Confirm that there is an animation in the inventory
        }
    }
 
    changed(integer change)
    {
        if (change & CHANGED_LINK) // Triggered when someone sits on the4 poseball. When you sit, you really link to the ball.
        {
            if(!used)
            {
                used = TRUE;
                user = llAvatarOnSitTarget();
                if(user == NULL_KEY) used = FALSE; // Make sure that there's really someone sitting on the poseball
                osAvatarStopAnimation(user, "sit"); // Stop the default sit animation (IMPORTANT!)
                osAvatarPlayAnimation(user, anim);  // And start the animation that we want started.
            } else {
                used = FALSE;
                osAvatarStopAnimation(user, anim); //Stop the animation when the user stands up.
                user = NULL_KEY; // Probably redundant, but we want to make sure that the value for ''user'' is empty.
            }
        }
 
        if(change & CHANGED_INVENTORY)
        {
            llResetScript(); // Reset the script if the inventopry has changed.
        }
    }
}
 
state error
{
    state_entry()
    {
        llOwnerSay("This poseball contains no animations. Please add one.");
    }
 
    changed(integer change)
    {
        if(change & CHANGED_INVENTORY)
        {
            llOwnerSay("Change detected. Initializing");
            llResetScript();
        }
    }
}
Personal tools
General
About This Wiki