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

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

Recommended Posts

Posted (edited)

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
Posted

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
Posted

have you tried something like...

changed(integer change)
{    
  if (change & CHANGED_TELEPORT) 
  { llSleep(5.0); llResetScript();
  }
}

 

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