Jump to content

hello help script animation sound with timer


Tzimix
 Share

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

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

Recommended Posts

Hello ,

I have a script that I put in a prim with my animation, but I would like to be able to integrate some modifications that I apparently can't do ^^ ^^.

I would like to know if by putting in my prim an animation and a sound it is possible that when I wear the prim it plays my animation and the sound at the same time as the animation with a style timer every 30 seconds.
I would like to know if I can put an animation and a sound instead of the animations in the object.

I put my script if ever a person has a light ^^ ^

 

string gAnimName = "anim";

default
{
state_entry()
{
llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION); // ask the owner for permission to trigger animations
llSetTimerEvent(0.5);//I added this line.
//llStartAnimation(gAnimName);

}

on_rez(integer param)
{
llResetScript(); // reset the script as soon as it starts.
}

attach(key id)
{
integer perm = llGetPermissions();

if (id != NULL_KEY) // make sure we're actually attached.
{
if (! (perm & PERMISSION_TRIGGER_ANIMATION)) // remember to use bitwise operators!
{
llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION); // request permissions from the owner.
}
}
else
{
if (perm & PERMISSION_TRIGGER_ANIMATION)
{
llStopAnimation(gAnimName); // stop the animation

}
}
}
timer()
{
llStopAnimation(gAnimName);
llStartAnimation(gAnimName);
}
} 

 

 

thank you in advance

 

 

Link to comment
Share on other sites

The most simple and easy approach would be to use a looped animation.  Regarding the sound, just loop the sound, until you stop the animation. Be sure to have a sound named "sound" and an animation named "anim" in the the object.

// If it works, I made it, else someone else did :D

string strAnim= "anim";
string strSound= "sound";
integer bActive= FALSE;

default
{
    state_entry()
    {
        llPreloadSound(strSound);
    }

    touch_end(integer num)
    {
        if (llGetPermissions() & PERMISSION_TRIGGER_ANIMATION)
        {
            if (bActive)
            {
                llStopAnimation(strAnim);
                bActive = FALSE;
                llStopSound();
            }
            else
            {
                llStartAnimation (strAnim);
                bActive = TRUE;
                llLoopSound( strSound, 1.0);
            }
        }
        else
        {
            llRequestPermissions(llDetectedKey(0), PERMISSION_TRIGGER_ANIMATION);
        }
    }
    
    run_time_permissions(integer perm)
    {
        if (perm & PERMISSION_TRIGGER_ANIMATION)
        {
            bActive= TRUE;
            llStartAnimation(strAnim);
            llLoopSound( strSound, 1.0);
        }
    }
}

 

Edited by Rachel1206
Link to comment
Share on other sites

Hello and thx Rachel1206

 

Thank you for your help
when I test the script, I have to click on the cube to start and stop the sound.

is it possible you think that the sound and the animation play together the time of the animation automatically when I carry the object . and that it is possible to set a timer so that the animation and the sound play together every 30 seconds for example .

miles thank you 

Link to comment
Share on other sites

Yes, by examining the attach event, which is triggered, when you attach "the box" instead of placing it on ground. Now, just cut and paste the code from the  touch_end(integer num) above.

    attach(key id)
    {
        if (id)     // is a valid key and not NULL_KEY
        {
		// handle animation/sound start/stop
        }
        else
        {
		// stop animation and sound as "box" is detached
        }
    }

Attach "the box" as a HUD - voila, you got HUD controlled animation, in this case though sound is limited to llTriggerSound, if you want others to hear it.

Edited by Rachel1206
Link to comment
Share on other sites

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