These forums are CLOSED. Please visit the new forums HERE
sound on sit |
|
SirFency Blackheart
Registered User
Join date: 6 Jan 2009
Posts: 81
|
09-29-2009 06:50
I want to play a sound when I sit on an object. I don't know how to check if I'm sitting. I found sound on touch scripts but this is not what I'm looking for. Any help on were to look for this would be greatly appreciated. Thanks!
|
EF Klaar
Registered User
![]() Join date: 11 Jun 2007
Posts: 330
|
09-29-2009 06:56
You could find a poseball script and add llPlaySound to it.
|
SirFency Blackheart
Registered User
Join date: 6 Jan 2009
Posts: 81
|
09-29-2009 06:59
why not just play a sound when I sit on the object?
|
Lear Cale
wordy bugger
![]() Join date: 22 Aug 2007
Posts: 3,569
|
09-29-2009 07:02
The "changed" event handler runs, with the CHANGED_LINK bit set in the integer argument, whenever anyone sits or stands from a scripted object or prim.
When someone sits, llAvatarOnSitTarget() will return the key of the sitter. When someone stands, it returns NULL_KEY. For this to work, the sit target has to be nonzero (set using llSitTarget()). Play a sound using the LL function for that purpose; I don't recall the name offhand. |
SirFency Blackheart
Registered User
Join date: 6 Jan 2009
Posts: 81
|
09-29-2009 07:19
thank you! I got it working.
|
SirFency Blackheart
Registered User
Join date: 6 Jan 2009
Posts: 81
|
09-29-2009 08:00
Well I thought I had it working. After I get up the sound keeps on playing. I want it to stop when I get up. What am I missing here?
What would be really cool is if I could make it play a different sound at night. default { state_entry() { // set sit target, otherwise this will not work llSitTarget(<0.0, 0.0, 0.1>, ZERO_ROTATION); } changed(integer change) { if (change & CHANGED_LINK) { key av = llAvatarOnSitTarget(); if (av) {//evaluated as true if not NULL_KEY or invalid llSay(0, "Hello " + llKey2Name(av) + "Just relax and listen to the birds for a while, you deserve it because your good enough, smart enough, and gosh darn it, people like you!" ![]() llLoopSound(llGetInventoryName(INVENTORY_SOUND,0),1); } } } } |
Argent Stonecutter
Emergency Mustelid
![]() Join date: 20 Sep 2005
Posts: 20,263
|
09-29-2009 08:24
if(av) {
... } else { llStopSound(...); } _____________________
Argent Stonecutter - http://globalcausalityviolation.blogspot.com/
"And now I'm going to show you something really cool." Skyhook Station - http://xrl.us/skyhook23 Coonspiracy Store - http://xrl.us/coonstore |
SirFency Blackheart
Registered User
Join date: 6 Jan 2009
Posts: 81
|
09-29-2009 08:32
thank you that worked.
|
Argent Stonecutter
Emergency Mustelid
![]() Join date: 20 Sep 2005
Posts: 20,263
|
09-29-2009 09:13
Also, to make the sound change at night, call llGetSunDirection and look at the sign of the Z component.
_____________________
Argent Stonecutter - http://globalcausalityviolation.blogspot.com/
"And now I'm going to show you something really cool." Skyhook Station - http://xrl.us/skyhook23 Coonspiracy Store - http://xrl.us/coonstore |
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
09-29-2009 09:26
Conveniently enough, the OP has just the script to do it too.
![]() _____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask....
![]() Look for my work in XStreetSL at |
SirFency Blackheart
Registered User
Join date: 6 Jan 2009
Posts: 81
|
09-29-2009 09:56
Yes I do have two scripts that when put together would do what I wanted but I don't understand how to write it. do I write another if else statement or do I include both conditions in one if else statement? I'm lost as to how its done.
|
Eli Schlegal
Registered User
![]() Join date: 20 Nov 2007
Posts: 2,387
|
09-29-2009 09:59
Just wondering... are you trying to make a whoopee cushion?
|
Argent Stonecutter
Emergency Mustelid
![]() Join date: 20 Sep 2005
Posts: 20,263
|
09-29-2009 10:01
// Add a new global variable "current sound"
string current_sound = ""; // ... if (av) { // ... vector sun = llGetSunDirection(); if(sun.z > 0) current_sound = "day sound"; else current_sound = "night_sound"; llLoopSound(current_sound, 1); } else { if(current_sound != "" ![]() llStopSound(current_sound); current_sound = ""; } _____________________
Argent Stonecutter - http://globalcausalityviolation.blogspot.com/
"And now I'm going to show you something really cool." Skyhook Station - http://xrl.us/skyhook23 Coonspiracy Store - http://xrl.us/coonstore |
SirFency Blackheart
Registered User
Join date: 6 Jan 2009
Posts: 81
|
09-29-2009 10:37
Just wondering... are you trying to make a whoopee cushion? No its a park bench that I want you to hear the birds when you sit on it and at night I want you to hear an owl rather than the chirping birds. But only when you sit on the bench because it would be annoying to hear that all the time. |