De DigiWiki.
// Basic Animation / Attachment 1.0
// Catherine Omega Heavy Industries
string gAnimName = "sit"; // what animation to play?
default
{
state_entry()
{
llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION); // ask the owner for permission to trigger animations
llStartAnimation(gAnimName); // automatically trigger animation.
}
on_rez(integer param)
{
llResetScript(); // reset the script as soon as it starts.
}
attach(key id)
{
integer perm = llGetPermissions();
if (id != NULL_KEY) // make sure we're actually attached.
{
if (! (perm & PERMISSION_TRIGGER_ANIMATION)) // remember to use bitwise operators!
{
llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION); // request permissions from the owner.
}
}
else
{
if (perm & PERMISSION_TRIGGER_ANIMATION)
{
llStopAnimation(gAnimName); // stop the animation
}
}
}
}