Difference between revisions of "User:Toady Nakamura/Hold Teddy Script"
Jump to navigation
Jump to search
m (put hold teddy script here) |
m (<source lang="lsl2">) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
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. | |||
<source lang="lsl2"> | |||
string anim ="Hold"; | string anim ="Hold"; // change this name to match the animation which is in the prim ! | ||
default | default | ||
{ | { | ||
state_entry() | |||
{ | |||
llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION); | |||
// ask the owner for permission to trigger animations | |||
llStartAnimation(anim); // automatically trigger animation. | |||
} | |||
attach(key wearer) | attach(key wearer) | ||
{ | { | ||
if(wearer == NULL_KEY) | if(wearer == NULL_KEY) | ||
{ | |||
llStopAnimation(anim); | llStopAnimation(anim); | ||
llSetTimerEvent(0); | llSetTimerEvent(0); | ||
Line 20: | Line 27: | ||
{ | { | ||
llRequestPermissions(wearer,PERMISSION_TRIGGER_ANIMATION); | llRequestPermissions(wearer,PERMISSION_TRIGGER_ANIMATION); | ||
} | |||
} | } | ||
run_time_permissions(integer permissions) | |||
{ | { | ||
if (PERMISSION_TRIGGER_ANIMATION & permissions) | if (PERMISSION_TRIGGER_ANIMATION & permissions) | ||
{ | { | ||
llStartAnimation(anim); | llStartAnimation(anim); | ||
llSetTimerEvent(15); | llSetTimerEvent(15); | ||
} | } | ||
Line 36: | Line 42: | ||
{ | { | ||
llStartAnimation(anim); | llStartAnimation(anim); | ||
} | |||
} | } | ||
</ | </source> | ||
== Credits & History == | |||
*Script originally from a class by Minx Mousehold, modified by [[User:Toady Nakamura|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 [http://lslwiki.net/lslwiki/wakka.php?wakka=llStartAnimation wiki_wakka!]) | |||
==More? == | |||
Visit my LSL wiki page for my library of simple scripts ! [[User:Toady Nakamura|Toady Nakamura]] |
Latest revision as of 13:37, 11 January 2016
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