// Play a sound whenever the owner is walking
integer gWasWalking; // TRUE when wearer is already walking
string gSound = "Sleepwalk"; // 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;
}
}