User:Toady Nakamura/Hold Teddy Script

From Second Life Wiki
< User:Toady Nakamura
Revision as of 14:37, 11 January 2016 by Toady Nakamura (talk | contribs) (<source lang="lsl2">)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

This script is useful for things like holding teddybears or sandwiches.

  • You need an animation to put in the same prim. Here I named the animation "Hold"
  • You have to change the animation name to the animation you include in the prim with the script.
string anim ="Hold"; // change this name to match the animation which is in the prim !

default
{
    state_entry()
    {
        llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION); 
        // ask the owner for permission to trigger animations
        llStartAnimation(anim); // automatically trigger animation.
    }


    attach(key wearer)
    {
    if(wearer == NULL_KEY)
        {
          llStopAnimation(anim);
          llSetTimerEvent(0);
        }
        else
        {
         llRequestPermissions(wearer,PERMISSION_TRIGGER_ANIMATION);
        }
    }

    run_time_permissions(integer permissions)
    {
        if (PERMISSION_TRIGGER_ANIMATION & permissions)
        {
        llStartAnimation(anim);
        llSetTimerEvent(15);
        }
    }

   timer()
   {
        llStartAnimation(anim);
   }    
}


Credits & History

  • Script originally from a class by Minx Mousehold, modified by Toady Nakamura
    • Modded again 08/06/12 to add state_entry after getting massive script errors - but only when worn by tinies!!

Big Scary Script Error

Here's the script error that you get if you don't have that state entry in the script & you're tiny

  • Script trying to stop animations but PERMISSION_TRIGGER_ANIMATION permission not set

Because ... although the PERMISSION_TRIGGER_ANIMATION permission is automatically granted when sitting, a prior call to llRequestPermissions is required! (Thank you wiki_wakka!)

More?

Visit my LSL wiki page for my library of simple scripts ! Toady Nakamura