Difference between revisions of "Walker Sound"
Jump to navigation
Jump to search
(Created page with "I've seen a lot of these around the grid, I've made this one as efficient as I can. To use it you can just put the script in a prim along with a sound, there is no need to modify…") |
(lsl tags) |
||
(3 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
I've seen a lot of these around the grid, I've made this one as efficient as I can. To use it you can just put the script in a prim along with a sound, there is no need to modify the script. But if you wanna do it, who's gonna stop ya? | I've seen a lot of these around the grid, I've made this one as efficient as I can. To use it you can just put the script in a prim along with a sound and then attach it to your avatar, there is no need to modify the script. But if you wanna do it, who's gonna stop ya? | ||
< | Thanks to [[User:Takni Miklos]] for some optimisations! | ||
<source lang="lsl2"> | |||
integer walking; | integer walking; | ||
string sound; | string sound; | ||
default | default | ||
{ | { | ||
Line 11: | Line 13: | ||
llResetScript(); | llResetScript(); | ||
} | } | ||
state_entry() | state_entry() | ||
{ | { | ||
Line 17: | Line 19: | ||
llSetTimerEvent(0.5); | llSetTimerEvent(0.5); | ||
} | } | ||
timer() | timer() | ||
{ | { | ||
Line 23: | Line 25: | ||
if(info & AGENT_WALKING) | if(info & AGENT_WALKING) | ||
{ | { | ||
if(walking | if(!walking) | ||
{ | { | ||
walking = TRUE; | walking = TRUE; | ||
Line 31: | Line 33: | ||
else | else | ||
{ | { | ||
walking = FALSE; | if(walking) | ||
{ | |||
walking = FALSE; | |||
llStopSound(); | |||
} | |||
} | } | ||
} | } | ||
} | } | ||
</ | </source> |
Latest revision as of 07:19, 3 December 2017
I've seen a lot of these around the grid, I've made this one as efficient as I can. To use it you can just put the script in a prim along with a sound and then attach it to your avatar, there is no need to modify the script. But if you wanna do it, who's gonna stop ya?
Thanks to User:Takni Miklos for some optimisations!
integer walking;
string sound;
default
{
on_rez(integer omitted)
{
llResetScript();
}
state_entry()
{
sound = llGetInventoryName(INVENTORY_SOUND, 0);
llSetTimerEvent(0.5);
}
timer()
{
integer info = llGetAgentInfo(llGetOwner());
if(info & AGENT_WALKING)
{
if(!walking)
{
walking = TRUE;
llLoopSound(sound, 1.0);
}
}
else
{
if(walking)
{
walking = FALSE;
llStopSound();
}
}
}
}