Jump to content

A walker that won't start until 5 seconds after a tp


Leo1452
 Share

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

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

Recommended Posts

Below is a basic walker script that's been shared around. Whenever I teleport to a person or location, it starts playing. I want make sure that it can't play until (let's say) 5 seconds after every teleport. It's because I already have a teleport sound player, so I don't want them both playing at the same time. I've tried adding llSleep(), but that just causes it to play 5 seconds later, even though I'm not even walking by then. I just want it to act as if I didn't walk at all no matter what my avatar does during the 5 seconds after every teleport.

string Snd = "Sleepwalk";
integer For = AGENT_WALKING;
default
{
    state_entry()
    {
        llPreloadSound(Snd);
        state entry;
    }
}
state entry
{
    state_entry()
    {
        llStopSound();
        @D;
        if (llGetAgentInfo(llGetOwner()) & For)
        {
            llSleep(2.0);
            state walking;
        }
        jump D;
    }
}
state walking
{
    state_entry()
    {
        llLoopSound(Snd,.0);
        float alpha = 0.0;
        @DD;
        llAdjustSoundVolume(alpha);
        alpha +=.1;
        if(alpha >= 1.0){jump D;}
        jump DD;
        @D;
        if (!(llGetAgentInfo(llGetOwner()) & For))
        {
            float alpha = 1.0;
            @DXD;
            llAdjustSoundVolume(alpha);
            alpha -=.1;
            if(alpha < 0.0){jump DX;}
            jump DXD;
            @DX;
            state entry;
        }
        jump D;
    }
}

 

Edited by Leo1452
Link to comment
Share on other sites

a way to do this is to take controls: forward, back, left and right

 when any of these movement keys are pressed then play the sound. When the keys are not pressed then stop the sound

example pcode:

attach(key id)
{
   if (id != NULL_KEY) // is attached
   {
      llRequestPermissions(id, PERMISSION_TAKE_CONTROLS);
   }
   else
   {
      if (llGetPermissions() & PERMISSION_TAKE_CONTROLS)
          llReleaseControls();
   }
}

run_time_permissions(integer perm)
{
   if (perm)
   {
      llPreloadSound(...);
      llTakeControls(CONTROL_FORWARD|CONTROL_BACK|CONTROL_LEFT|CONTROL_RIGHT, ...);
   }
}

controls(integer level, integer edge)
{
    if (level & edge)  // key down
    {
    
       llLoopSound(...);
    
    }
    else if (edge)     // key up
    {
    
       llStopSound();

    }
}

 

  • Like 1
Link to comment
Share on other sites

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...