Jump to content
You are about to reply to a thread that has been inactive for 126 days.

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

Recommended Posts

Posted

I'm trying to make a script to send a request to perform animation for other avatars.
I have 3 animations to execute in sequence anim1, anim2 and anim3.
Each animation runs for 10 seconds, so I created a timer lasting 10 seconds to run the animations.
I'm having trouble getting all the avatars to execute all the animations.

My script has a problem that only the last guest avatar is executing the animations in sequence.

 

list gAnimations = ["anim1", "anim2", "anim3"];
integer gMaxAnimations;
string gAnimation;
string gLastAnimation;
integer gIndexAnimation = 0;
integer gStopAnimation = 0;

list gAvatars = ["uui_avatar1", "uui_avatar2"]; //not real value

integer gRunning = 0;

default
{
    state_entry()
    {
        gMaxAnimations = llGetListLength(gAnimations);
    }

    touch_start(integer total_number)
    {
        gRunning = 0;
        llSetTimerEvent(0.1);
    }
    
    timer()
    {
        if(gRunning == 0)
        {            
            gRunning = 1;
            gIndexAnimation = 0;            
            gAnimation  = llList2String(gAnimations, gIndexAnimation);
            gLastAnimation = "";
            gStopAnimation = 0;
            
            llOwnerSay("animation => " + gAnimation);
            llOwnerSay("Last dance => " + gLastAnimation);
            llOwnerSay("----------------------------------------------");
            
            integer i;
            for(i=0;i<llGetListLength(gAvatars);i++)
            {
                llRequestPermissions(llList2Key(gAvatars, i), PERMISSION_TRIGGER_ANIMATION);    
            }
            
            gIndexAnimation++;  
            llSetTimerEvent(5.0);      
        }
        else if(gRunning == 1)
        {
            
            
            if(gIndexAnimation < gMaxAnimations)
            {
                gAnimation =  llList2String(gAnimations, gIndexAnimation);
                gLastAnimation = llList2String(gAnimations, gIndexAnimation - 1);
                gStopAnimation = 1;
                
                llOwnerSay("dance => " + gAnimation);
                llOwnerSay("Last dance => " + gLastAnimation);
                llOwnerSay("----------------------------------------------");
                
                /*
                integer i = 0;
                for(i=0;i<llGetListLength(gAvatars);i++)
                {
                    llRequestPermissions(llList2Key(gAvatars, i), PERMISSION_TRIGGER_ANIMATION);    
                }
                */
                llStopAnimation(gLastAnimation);
                llStartAnimation(gAnimation);
                
                gIndexAnimation++;
            }
            else
            {
                gIndexAnimation = 0;
            }
        }        
    }
    
    run_time_permissions(integer perm)
    {        
        if (perm & PERMISSION_TRIGGER_ANIMATION)
        {
            if (gStopAnimation)
            {
                llStopAnimation(gAnimation);
            }
            else 
            {
                if(gLastAnimation != "")
                    llStopAnimation(gLastAnimation);
            
                if(gAnimation != "")
                    llStartAnimation(gAnimation);
            }
        }
        else
        {
            llOwnerSay("The avatar didn't accept the dance invitation.");
        }
    }

}

Posted

As per lsl wiki:

  • Scripts may hold permissions for only one agent at a time. To hold permissions for multiple agents you must use more than one script.

So you need a separate script for each invited dancer to keep the granted permission.

In your script the for loop requesting permissions keeps only the last permission. That’s why only the last avatar dances :)

Posted (edited)
55 minutes ago, Marvin Benelli said:

So you need a separate script for each invited dancer to keep the granted permission.

or the script needs to be compiled to an experience that is enabled on the land where it is running, or the dancers need to be sat on the object. (with different script changes for either)

Edited by Quistess Alpha
Posted
4 hours ago, Marvin Benelli said:

As per lsl wiki:

  • Scripts may hold permissions for only one agent at a time. To hold permissions for multiple agents you must use more than one script.

So you need a separate script for each invited dancer to keep the granted permission.

In your script the for loop requesting permissions keeps only the last permission. That’s why only the last avatar dances :)

Sorry I'm new to programming.

So if I need to animate 50 avatars, will I need 50 scripts?

You are about to reply to a thread that has been inactive for 126 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
×
×
  • Create New...