Jump to content

Animation Script?


Misy Pera
 Share

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

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

Recommended Posts

Hello, I'm confised!  Lol!  I tend to not work with animation because I have a hard time with animation scripts but I decided to work on that,

 

I think I'm just missing something obvious, I hope anyways.

I have a table with two chairs.  Each chair has it's own animation and things that should happen when the avatar on that chair sits or stands, but regardless of what I've tried if I sit, then stand on Chair B the Chair A script is triggered.

 changed(integer change)
    {
        if (change & CHANGED_LINK)
        {
            key avatar = llAvatarOnLinkSitTarget(LINK_THIS);
            if (llKey2Name(avatar) != "")
            {
                llRequestPermissions(avatar, PERMISSION_TRIGGER_ANIMATION);
            }
            else if (llAvatarOnLinkSitTarget(LINK_THIS)==NULL_KEY)
            {
     Tellerout();
                if ((llGetPermissions() & PERMISSION_TRIGGER_ANIMATION) && sitting && llKey2Name(avatar) != "")
                {
                    llStopAnimation("Stand");
                    llStopAnimation("Teller");
                }
                sitting = 0;
            }
        }
        if (change & CHANGED_OWNER + CHANGED_REGION_START + CHANGED_INVENTORY)
        {
            llResetScript();
        }
    }

 

Link to comment
Share on other sites

The logic is mildly tricky because you're not interested simply in whether the number of sitting avs has changed but also in whether it changed because someone sat down.  You want to ignore people who stand up.  Note that the last person to sit is also the last link in the object's linkset, so that's the one you want to get permissions from -- but ONLY if that person just sat down, not if he was already seated and the other guy stood.  How do you do that?  The trick is to get some way to tell whether the number of sitters increased or decreased.  You compare llGetNumberOfPrims with llGetObjectPrimCount and you track how the difference between them changes.  Here's a rough script (not tested in world but probably right) that does the bare bones:

integer gWasSeated;key gAv1;key gAv2;default{    state_entry()    {        llLinkSitTarget(1,<0.0,0.0,0.5>,ZERO_ROTATION);        llLinkSitTarget(2,<0.0,0.0,0.5>,ZERO_ROTATION);    }    changed(integer change)    {        if (change & CHANGED_LINK)        {            gAv1 = llAvatarOnLinkSitTarget(1);            gAv2 = llAvatarOnLinkSitTarget(2);            integer IsSeated = llGetNumberOfPrims() - llGetObjectPrimCount(llGetKey()); // The number of people seated now            if (IsSeated > gWasSeated)  // New av has sat down.  Ignore what happens if someone stands up.            {                if (gAv1 == llGetLinkKey(llGetNumberOfPrims()) ) // It was the av on sit target 1                {                    llRequestPermissions(gAv1,PERMISSION_TRIGGER_ANIMATION);                }                else  // No, it was the av on sit target 2                {                    llRequestPermissions(gAv2,PERMISSION_TRIGGER_ANIMATION);                }            }            gWasSeated = IsSeated;        }    }        run_time_permissions(integer perm)    {        if (perm & PERMISSION_TRIGGER_ANIMATION)        {            llStopAnimation("stand");            llStartAnimation("Teller");        }    }}

 EDIT -- In case it's not clear yet, the last av in the linkset is always the one whose UUID is

llGetLinkKey(llGetNumberOfPrims()) 

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2936 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...