Difference between revisions of "User:Toady Nakamura/Hold Teddy Script"
Jump to navigation
Jump to search
m (minor edit & watch) |
m (added state_entry & discussion of why needed !!) |
||
Line 2: | Line 2: | ||
*You need an animation to put in the same prim. Here I named the animation "Hold" | *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. | *You have to change the animation name to the animation you include in the prim with the script. | ||
<lsl> | <lsl> | ||
Line 10: | Line 9: | ||
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); | ||
} | |||
} | } | ||
</lsl> | </lsl> | ||
== 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!]) |
Revision as of 20:26, 5 August 2012
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.
<lsl>
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); }
}
</lsl>
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!)