Difference between revisions of "AGENT WALKING"

From Second Life Wiki
Jump to navigation Jump to search
m
(Add an example)
Line 7: Line 7:
|text=
|text=
|pb=
|pb=
|examples
|examples=Cause a sound to be played while the wearer of the hud or attachment is walking.
Place this script in a Hud for the owner only to hear the sound,
or in an attachment for others to hear your footsteps too.
You'll need a sound file in the object too, with your choice of footstep sounds.
<lsl>
// Play a sound whenever the owner is walking
integer  gWasWalking;            // TRUE when wearer is already walking
string    gSound = "footsteps";    // name of soundfile in inventory
default
{
    state_entry()
    {
        // Start a timer to continuously check if the owner is walking
        llSetTimerEvent(0.25);
    }
    timer()
    {
        integer NowWalking = llGetAgentInfo(llGetOwner()) & AGENT_WALKING;
        if  (NowWalking != gWasWalking)        // walking has stopped or started
        {
            llStopSound();
            if (NowWalking)      llLoopSound(gSound, 1.0);
        }
        gWasWalking = NowWalking;
    }
}
</lsl>
|constants=
|constants=
<!--{{LSL ConstRow|CHANGED_SHAPE}}-->
<!--{{LSL ConstRow|CHANGED_SHAPE}}-->

Revision as of 13:39, 22 December 2013

Description

Constant: integer AGENT_WALKING = 0x0080;

The integer constant AGENT_WALKING has the value 0x0080

Caveats


Related Articles

Functions

•  llGetAgentInfo

Examples

Cause a sound to be played while the wearer of the hud or attachment is walking. Place this script in a Hud for the owner only to hear the sound, or in an attachment for others to hear your footsteps too. You'll need a sound file in the object too, with your choice of footstep sounds. <lsl> // Play a sound whenever the owner is walking integer gWasWalking; // TRUE when wearer is already walking string gSound = "footsteps"; // name of soundfile in inventory default {

   state_entry()
   {
       // Start a timer to continuously check if the owner is walking
       llSetTimerEvent(0.25);
   }
   timer()
   {
       integer NowWalking = llGetAgentInfo(llGetOwner()) & AGENT_WALKING;
       if  (NowWalking != gWasWalking)        // walking has stopped or started
       {
           llStopSound();
           if (NowWalking)      llLoopSound(gSound, 1.0);
       }
       gWasWalking = NowWalking;
   }

} </lsl>

Deep Notes

Search JIRA for related Issues

Signature

integer AGENT_WALKING = 0x0080;