Jump to content

A fix to a dancer script?


lilricecakes
 Share

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

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

Recommended Posts

Ive recently made my own dancer, and gotten it to play my animations and sounds! There is one issue however, the animations dont play one after the other but instead at random intervals. Is there a way i can fix this where they can play in succession? 

 

integer ON = 0;                    //STATE OF SCRIPT
//YOU EDIT THESE PARTS FOR NEW ANIMATIONS, SOUND CLIPS ETC. DO NOT TOUCH THE SCRIPT
list animation = ["Sync'D Motion__Originals - Boasty 01", "Sync'D Motion__Originals - Boasty 02","Sync'D Motion__Originals - Boasty 03","Sync'D Motion__Originals - Boasty 04","Sync'D Motion__Originals - Boasty 05"];     //ANIMATION NAMES
integer MaxSoundClips = 18;         //AMOUNT OF SONG CLIPS, NAME THEM 1,2,3,4,ETC 
integer SoundLength = 10;           //FIRST SERIES OF SOUND LENGTHS
integer LastSoundLength = 8;       //INCASE LAST SOUND CLIP IS SHORTER
integer SoundClipNumber = 0;       //FOR SOUND LOOP
integer AnimPos;

ResetToDefault()
{
    llStopSound();
    llSetTimerEvent(0.00);
    ON = 0;
    SoundClipNumber = 0;
    AnimPos = 0;
    llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
}

StopAnims() {
    integer x;
    for (x=0;x<llGetListLength(animation);x++) {
        llStopAnimation(llList2String(animation,x));
    }
}

    
default
{
    state_entry()
    {
        llListen(0, "", "", "");
    }
    
    attach(key id)
    {
        if(id)
        {
            llOwnerSay("Say 'on' or 'off'");
        }
        else ResetToDefault();
    }

    timer()
    {
        llPlaySound((string)(++SoundClipNumber),1.0);
        llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
        
        if(ON == 1){
            llSetTimerEvent(SoundLength); 
            ON = 2;
        }
        if(SoundClipNumber == MaxSoundClips) {
            llSetTimerEvent(LastSoundLength); 
            ON = 1; SoundClipNumber = 0;
        }
        llPreloadSound((string)(SoundClipNumber+1));
    }
    
    listen(integer channel, string name, key id, string message)
    {
        message = llToLower(message);
        if (ON == 0 && message == "on")
        {
            ON = 1;
            llRequestPermissions(id, PERMISSION_TRIGGER_ANIMATION);
            llSetTimerEvent(0.01);
        }
        else if(message == "off"){ResetToDefault();}
    }
    
    run_time_permissions(integer perm)
    {
        if (perm & PERMISSION_TRIGGER_ANIMATION)
        {
            llStopAnimation("sit");
            StopAnims();
            if ((ON == 1) || (ON == 2)) {
                llStartAnimation(llList2String(animation,AnimPos));
                AnimPos++;
            }
            if (AnimPos == llGetListLength(animation)) AnimPos = 0;
        }
    }
}
 

Link to comment
Share on other sites

It should be triggering your anims in order already, because you are incrementing AnimPos by one each time you enter the run_time_permissions event and then starting the next anim in the animation list.  You can check to be sure which anim should be playing by using llOwnerSay to tell you the value of AnimPos before you run the anim.  In fact, you can put diagnostic statements at a few key spots to narrow down whatever is misbehaving now.

You can simplify your script significantly by calling llRequestPermissions one time only, when you attach the dance object.  After that, the object will always have permissions, so you only need to stop the current anim and start the next one.  You don't need to go through the run_time_permissions event over and over again.  You also don't need to loop through stopping every single anim each time, since only the currently triggered one is running anyway, and you know which one that is.  Eliminate the StopAnims function and just call llStopAnimation for that one anim.  Finally, I may be missing something, but I don't see why ON ever needs to be anything other than 0 or 1.  I suspect that once you simplify the code a bit, you will discover whatever is making it behave improperly right now.

Link to comment
Share on other sites

  • 2 weeks later...

As what Rolig said and I would check your pre-loading  of sound . There is working examples on outwordlz.com of scripts for this .

Its possible your script is pre-loading  sound which takes a while  sometimes 28s and then your are playing new song immediately your que one will then start up.  I use llTriggerSound, I also note you don't have  llSetSoundQueueing(TRUE)   set in your script  

 

 

Link to comment
Share on other sites

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