The project name originates from an avatar that I made, that required a "folded" animation to run. The animation was named "folded" and thus the script was named "stayfolded".
While this script has application for boxy/robotic/non-articulated avatars (daleks, etc).. it also has equal application for "holding a teddy bear"..or a sign, or anything that requires an animation to run, and keep running.
Now, I realize there are issues with animation priorities, that simply can't be solved easily.. and the solutions I have found, tend to be worse than the problem. So, for the moment, let's set aside the issue of competing P4 animations.
The issue is simply this.. how do I start the animation "on wear" and then anticipate and deal with, the types of situations that tend to "release" animations (teleporting for example). And how do I reassert the hold/fold animation when it does "get bumped"? I'd like to avoid installing a franimation/zhao AO with the same animation in every slot.
Here's my code, for what I have now. If anyone has any suggestions, please let me know. Am I missing some obvious cases? Am I doing something hideously wrong?
CODE
string anim;
integer gotPerms = FALSE;
init()
{
llSetTimerEvent(0);
gotPerms = FALSE;
anim = llGetInventoryName(INVENTORY_ANIMATION, 0);
}
getPerms()
{
gotPerms = FALSE;
llRequestPermissions(llGetOwner(),PERMISSION_TRIGGER_ANIMATION);
// no idea why it splits "TRIGG ER" like that on the forums.
}
playAnim(integer toggle)
{
if (!gotPerms) getPerms();
else
{
if (toggle)
{
llStartAnimation(anim);
}
else
{
llStopAnimation(anim);
}
}
}
default
{
state_entry()
{
init();
getPerms();
}
on_rez(integer startparam)
{
llResetScript();
}
run_time_permissions(integer perm)
{
if(perm & PERMISSION_TRIGGER_ANIMATION)
{
gotPerms = TRUE;
llSetTimerEvent(1);
playAnim(TRUE);
}
else
{
init();
getPerms();
}
}
changed (integer change)
{
if (change & CHANGED_LINK)
{
llResetScript();
}
if (change & CHANGED_TELEPORT && gotPerms)
{
init();
getPerms();
}
}
timer()
{
integer worn;
if (llGetAttached() == 0) worn = TRUE;
else worn = FALSE;
playAnim(worn);
}
}

