Simple Poseball (LSL)

From Catznip
Revision as of 10:40, 12 September 2014 by Trinity Dejavu (talk | contribs) (MIT Licence)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This example script provides the bare essentials for a simple pose ball. It has a tiny memory footprint and uses as few script resources as possible.

Instructions

  • Rez a prim and add the following script.
  • Edit the configuration options if required.
  • Add an animation to the prim.
  • Sit on the prim.

Memory can be further reduced by manually inlining the global variables, probably overkill.

MIT Licence

Copyright (C) 2014 Catznip Viewer (http://catznip.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

// Simple Poseball Script
// Copyright (C) 2014 Trinity Dejavu (Catznip Viewer http://catznip.com)
// Released under the MIT Licence (http://opensource.org/licenses/MIT)

// Documentation
// http://catznip.com/index.php/Simple_Poseball_(LSL)



// position to sit on the ball e.g <0,0,0.5>
// sit  0.5 meter above the ball
vector POSITION=<0.0, 0.0, 0.43>;

// hovertext above ball. "" for none.
// add '\n ' at the end to move text up i.e.
// string HOVERTEXT="Sit Here\n ";
string HOVERTEXT="";

// Pie Menu Sit Text. Will only work for the
// main prim but included it anyway. If no text
// is entered between "" it won't be used.
string SIT_TEXT="";


default {
    state_entry() {
        // Set the sit text message (if one has been specified above)
        if (SIT_TEXT != "") {
            llSetSitText(SIT_TEXT);
        }
        // Sit target - The offset for the avatar in relation to the poseball
        llSitTarget(POSITION, ZERO_ROTATION); 

        // Set the hover text
        llSetText(HOVERTEXT,<1,1,1>,1.0);
    }
    
    changed(integer change) { 
        // Someone sat or stood up
        if (change & CHANGED_LINK) {
            
            if (llAvatarOnSitTarget() != NULL_KEY)  { 
                // Yes we have someone, ask for permissions (this triggers run_time_permissions below)
                llRequestPermissions(llAvatarOnSitTarget(), PERMISSION_TRIGGER_ANIMATION);
            } else {
                // Nope .. no one, put the hover text back
                llSetText(HOVERTEXT,<1,1,1>,1.0);
            }
        }
    }

    run_time_permissions(integer perm) {
        if (perm & PERMISSION_TRIGGER_ANIMATION) {
            // Someone just got granted anim permissions
            // Stop the default linden sit
            llStopAnimation("sit");

            // Start the 1st animation in this prim
            llStartAnimation(llGetInventoryName(INVENTORY_ANIMATION,0));

            // Clear the hover text
            llSetText("",<0,0,0>,0.0);
        }
    }


}