I wonder what script should I use , when i have a sound i boots and want that it only sound when i move
Ty
These forums are CLOSED. Please visit the new forums HERE
sound script |
|
|
Rosele Maroon
Registered User
Join date: 17 Jan 2007
Posts: 61
|
09-08-2008 08:15
I wonder what script should I use , when i have a sound i boots and want that it only sound when i move
Ty |
|
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
|
09-08-2008 09:31
you would want to use a script that checks if the avatar is walking (can be create lag if you have it check too often) but you don't want the time in between checks to be too long or it won't always respond. i can probably whip up a simple one for you when i get home tonight if someone doesn't beat me to it.
|
|
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
|
09-08-2008 09:50
this one may work, (not at home to check it, so i can't tell you for sure) it's a modified version of the one i found here:
/54/4e/219020/1.html string walksound = "sound uuid or name here";//uuid of sound, or name of sound if it's in the inventory default { on_rez (integer foo) { llResetScript(); } state_entry() { llSetTimerEvent(0.1);//triggers the timer every 1/10th of a second, change to desired time } timer() { integer IsAvWalking = llGetAgentInfo (llGetOwner()); llPreloadSound(walksound);//preloads the sound to insure that it is heard at the correct time if (IsAvWalking & AGENT_WALKING) { llLoopSound(walksound, 1.0);//plays the sound continuesly at full volume, change to desired volume decimal (anywhere between 0.0-1.0) else{llStopSound(walksound);}//stops the sound if avatar isn't walking } } } edit: changed to loop sound, and added a stop sound if avatar isn't walking |
|
Rosele Maroon
Registered User
Join date: 17 Jan 2007
Posts: 61
|
09-08-2008 14:58
thank you so much
) |
|
Day Oh
Registered User
Join date: 3 Feb 2007
Posts: 1,257
|
09-08-2008 15:03
I hope this doesn't seem rude, but some of the behaviors of the script posted should be avoided, such as calling llPreloadSound repeatedly, and calling llLoopSound repeatedly when walking... Please consider using this one instead:
key owner_key; integer owner_walking; default { state_entry() { llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS); llSetTimerEvent(0.25); owner_key = llGetOwner(); } changed(integer change) { if(change & CHANGED_OWNER) { owner_key = llGetOwner(); } } on_rez(integer param) { llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS); } run_time_permissions(integer perm) { llTakeControls(CONTROL_UP, FALSE, TRUE); } timer() { integer walking = (llGetAgentInfo(owner_key) & AGENT_WALKING) != 0; if(walking) { if(!owner_walking) { llLoopSound(llGetInventoryName(INVENTORY_SOUND, 0), 1.0); } } else { if(owner_walking) { llStopSound(); } } owner_walking = walking; } } Best wishes ![]() _____________________
![]() |
|
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
|
09-08-2008 18:38
I hope this doesn't seem rude, but some of the behaviors of the script posted should be avoided, such as calling llPreloadSound repeatedly, and calling llLoopSound repeatedly when walking... Please consider using this one instead: Best wishes ![]() , the preloadsound isn't really needed, i just thru it in there to insure it's heard at the right time(not some seconds later) it would be odd for someone to walk a couple steps, and then a few seconds later you hear it. but then again, this is secondlife lol. but you said to avoid looping sound, but you still used it in your script. i thought for a second, doesn't llTriggerSound only play the sound once? i guess that's all that would be needed since it's playing it on each timer event, and not triggering again if the avatar's not walking. oh, and not rude at all, i never said the script wouldn't be laggy. i did mention that using timers will create lag. and i never said i was a great scripter, jsut tryin to help and definetly welcome otehr tips to improve on it. i've only been on sl for less than a year, and i know many of the scripters in this forum have been on there even since the beginning and have much more scripting knowledge than me ![]() |
|
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
|
09-08-2008 18:43
btw, what is take controls for in your script? i don;t see them being used for anything, just wondering
|
|
Day Oh
Registered User
Join date: 3 Feb 2007
Posts: 1,257
|
09-08-2008 18:52
Sure
![]() The first script calls llLoopSound 10 times per second if the owner is walking, whereas the second one only calls llLoopSound when the owner begins walking. The llTakeControls was solely to ensure the script will still run on parcels that have scripts disabled... I wonder if that's rude Now that you mention it, I guess the script could be adjusted to use control events instead of the timer! ![]() _____________________
![]() |
|
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
|
09-08-2008 19:35
Sure ![]() The first script calls llLoopSound 10 times per second if the owner is walking, whereas the second one only calls llLoopSound when the owner begins walking. hmm, looks about the same to me since it's within the timer event that checks if the owner is walking. i assume the true/false integer is meant somehow there, but isn't the timer also checking the status of that on each event and calling the loop sound if it's true? The llTakeControls was solely to ensure the script will still run on parcels that have scripts disabled... I wonder if that's rude Now that you mention it, I guess the script could be adjusted to use control events instead of the timer! ![]() that is probably a great idea, that would probably help eliminate lag created with the timer since the event would only be called if the avatar is pressing the keys asked for (even when sitting though i assume) |