Jump to content

Help with auto-cycling animations


Gage Verity
 Share

You are about to reply to a thread that has been inactive for 4079 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I'm trying to make a pose stand for model bots that will cycle through animations on a timer.  Its basically working, but at the moment when it gets to the last animation in the inventory it does not switch back to the first animation on the next cycle.  Been working on it for 2 days looking through other examples and help threads and can't seem to get it.

Here's what I have.  The llsay's are just in there for debug purposes.

 

integer ThisAnim = 0;
integer NumAnims = 0;
string CurrAnim;
key av;
float seconds=5.0; //Change to specify number of seconds between animations
default
{
on_rez(integer start_param)
{
llResetScript();
llSetAlpha(1.0,ALL_SIDES); // start off visible
}
state_entry()
{
NumAnims = llGetInventoryNumber(INVENTORY_ANIMATION);
CurrAnim=llGetInventoryName(INVENTORY_ANIMATION,0);

if(llGetInventoryType(CurrAnim)!=INVENTORY_ANIMATION)
{
CurrAnim = "sit";
llOwnerSay("Please put an animation in me"); 
}
llSitTarget(<0.0, 0.0, 1.0>, ZERO_ROTATION);
}

timer()
{

if(NumAnims != 0)
{
CurrAnim = llGetInventoryName(INVENTORY_ANIMATION, ThisAnim%NumAnims);
llStartAnimation(CurrAnim);
++ThisAnim;
ThisAnim = ThisAnim%NumAnims;
}
else
{
llSay(PUBLIC_CHANNEL, "WTF MATE No Animations");

}

}

changed(integer change)
{
llSay(PUBLIC_CHANNEL, "Changed Function");
if (change & CHANGED_LINK)
{
if (llAvatarOnSitTarget() != NULL_KEY) {
av = llAvatarOnSitTarget();
llRequestPermissions(av, PERMISSION_TRIGGER_ANIMATION);
}
else
{
if(llGetPermissions()&PERMISSION_TRIGGER_ANIMATION){
llStopAnimation(CurrAnim);

llSetAlpha(1.0,ALL_SIDES);
llSetTimerEvent(0);
}
}

else if (change & CHANGED_INVENTORY)
{
CurrAnim=llGetInventoryName(INVENTORY_ANIMATION,0);
if(llGetInventoryType(CurrAnim)!=INVENTORY_ANIMATION)
{
CurrAnim = "sit";
llOwnerSay("Please put an animation in me");
}
}
}
run_time_permissions(integer permissions)
{
llSay(PUBLIC_CHANNEL, "run time function");
if(permissions & PERMISSION_TRIGGER_ANIMATION)
{
llStopAnimation("sit");
llStartAnimation(CurrAnim);
llSetTimerEvent(seconds);
llSetAlpha(0.0,ALL_SIDES);
}
}
}

 

Link to comment
Share on other sites

Playing with your script in-world gave me a syntax error as copy-pasted from here.  You're missing a } on line 59 right before

else if (change & CHANGED_INVENTORY)

 


After that, your animations iterate correctly ( I stuck an llOwnerSay() in there to ensure) ... but once all of them are loaded, no animation overrides another ... so ... on line 30, before setting CurrAnim ...

if(NumAnims != 0)    llStopAnimation(CurrAnim); <--ADD THIS BIT RIGHT HERE   CurrAnim = llGetInventoryName(INVENTORY_ANIMATION, ThisAnim%NumAnims);

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4079 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...