Difference between revisions of "AGENT WALKING"
Jump to navigation
Jump to search
Mako Nozaki (talk | contribs) m |
Omei Qunhua (talk | contribs) (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
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
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>