Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Help Needed: "Stay Folded" (LVL: Medium/Advanced)

Winter Ventura
Eclectic Randomness
Join date: 18 Jul 2006
Posts: 2,579
02-06-2009 20:29
The project: "Stay Folded"

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);
}
}
_____________________

● Inworld Store: http://slurl.eclectic-randomness.com
● Website: http://www.eclectic-randomness.com
● Twitter: @WinterVentura
Lightwave Valkyrie
Registered User
Join date: 30 Jan 2004
Posts: 666
02-07-2009 00:02
two years ago i made the robots Hack & Slash from ReBoot
they required the legs to stay folded this is the script i wrote then

CODE

string stand = "StayFolded";
default
{
state_entry()
{
llSetTimerEvent(0.0);
}

attach(key id)
{

if (id != NULL_KEY)
{
llRequestPermissions(id,PERMISSION_TRIGGER_ANIMATION);
llStartAnimation(stand);
llSetTimerEvent(1.0);
}

}
timer()
{
llStartAnimation(stand);
}
}


note: PERMISSION_TRIGGER_ANIMATI ON has the extra space that lindens insist we have in the forums but needs to be removed to work
_____________________
L$ is the root of all evil
videos work! thanks SL :)