Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Sound problem with sliding door

Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
08-05-2009 15:01
From: Ponsonby Low
Rolig, I thank you again as I did learn from this. I find that the sound comes late, but it does come. (I tried slowing down the slide, hoping a slower movement would sync up with the sound, by adding to the number of steps:

changing

CODE

integer slice = 4; // how many steps during open and close
key open_sound = "9f989554-e5d4-5c9b-d7a9-73485d6e76ff";
key close_sound = "9f989554-e5d4-5c9b-d7a9-73485d6e76ff";

slide( vector tgt )
{
vector npos = llGetPos();
vector delta = (tgt - npos)/slice;
integer s;
for( s=1; s < slice; ++s )


to

CODE

integer slice = 10; // how many steps during open and close
key open_sound = "9f989554-e5d4-5c9b-d7a9-73485d6e76ff";
key close_sound = "9f989554-e5d4-5c9b-d7a9-73485d6e76ff";

slide( vector tgt )
{
vector npos = llGetPos();
vector delta = (tgt - npos)/slice;
integer s;
for( s=4; s < slice; ++s )


.....but that doesn't seem to be it. (Sometimes I can clearly see in a script where things like volume and speed can be changed, and sometimes I can't see them...all part of the learning process, of course.)

Where's the llPlay Sound? Surely not in the for loop you showed half of in this post.....
_____________________
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
Ponsonby Low
Unregistered User
Join date: 21 May 2008
Posts: 1,893
08-05-2009 15:02
Here it is (I did space after the less-than sign, here):

CODE
// Create door.  X is up/down, Y is open close.
// Put script in door.
// Set door at closed position, then reset script.

// Touch to open or close, or closes on timer

vector pos; // closed position when script is reset
vector opos; // open position
rotation rot;
float amt = 3.2; // how far to slide, in meters
integer dir = -1; // direction to slide. change sign to switch
float offset = 0.1; // a little in or out as opposed to left right.
integer open; // TRUE is open.
float delay = 20; // seconds to stay open
integer slice = 10; // how many steps during open and close
key open_sound = "9f989554-e5d4-5c9b-d7a9-73485d6e76ff";
key close_sound = "9f989554-e5d4-5c9b-d7a9-73485d6e76ff";

slide( vector tgt )
{
vector npos = llGetPos();
vector delta = (tgt - npos)/slice;
integer s;
for( s=4; s < slice; ++s )
{
npos += delta;
llSetPos( npos );
}
llSetPos(tgt);
}

close()
{
llSetTimerEvent(0);
slide(pos);
llSetPos(pos);
llSetRot(rot);
open = FALSE;
}


default
{
state_entry()
{
llPreloadSound(open_sound);
pos = llGetPos();
rot = llGetRot();
opos = pos + dir*(< 0,amt,offset>*rot); // assumes x axis is UP
open = FALSE;
}
on_rez(integer n)
{
llResetScript();
}

touch_start(integer total_number)
{
if( open )
{
close();
}
else
{
slide(opos);
llSetTimerEvent(delay);
open = TRUE;
llPlaySound(open_sound, 0.6);
llPlaySound(close_sound, 0.6);
}


}

timer()
{
close();

}


}
_____________________
War is over---if you want it.

P Low Low P Studio SMALL PARCEL SOLUTIONS: Homes & shops of distinction, with low prim-counts, surprisingly low prices!
Ponsonby Low
Unregistered User
Join date: 21 May 2008
Posts: 1,893
08-05-2009 15:03
(oh dear, why isn't the php thing working? Maybe I need to unclick the AutoParse Links box, as with posting URLs....)

EDIT--no, that didn't do a particle of good. Maybe I need to be in Standard option rather than Basic!?!?
_____________________
War is over---if you want it.

P Low Low P Studio SMALL PARCEL SOLUTIONS: Homes & shops of distinction, with low prim-counts, surprisingly low prices!
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
08-05-2009 15:10
it is working, what you probably need is the bbc encoder thing, because bbc code doesn't work in the forums
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369
Ponsonby Low
Unregistered User
Join date: 21 May 2008
Posts: 1,893
08-05-2009 15:12
Well, today is definitely a good Learning day--'bbc encoder' is also completely new to me. (What does the Beeb have to do with LSL!?!?!? ^_^)

In answer to your earlier question: llPlaySound ended up there after Slide.
_____________________
War is over---if you want it.

P Low Low P Studio SMALL PARCEL SOLUTIONS: Homes & shops of distinction, with low prim-counts, surprisingly low prices!
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
08-05-2009 15:18
Put the llPlaySound(open_sound) BEFORE the slide() call.
_____________________
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
Ponsonby Low
Unregistered User
Join date: 21 May 2008
Posts: 1,893
08-05-2009 15:21
It worked!! Thank you, thank you!
_____________________
War is over---if you want it.

P Low Low P Studio SMALL PARCEL SOLUTIONS: Homes & shops of distinction, with low prim-counts, surprisingly low prices!
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
08-05-2009 16:11
From: Ponsonby Low
Well, today is definitely a good Learning day--'bbc encoder' is also completely new to me. (What does the Beeb have to do with LSL!?!?!? ^_^)

In answer to your earlier question: llPlaySound ended up there after Slide.


it keeps the formatting from copying and pasting from the script to the forum, so it's easier to read, but since it's disabled in the forums, using it doesn't do what it's supposed to, so using the encoder for greasemonkey, it "fixes" it so it appears as it's supposed to, it's also useful for posting links.
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369
Ponsonby Low
Unregistered User
Join date: 21 May 2008
Posts: 1,893
08-05-2009 17:59
Sounds like something I need to get, if I'm going to continue to try to learn scripting (thanks!)
_____________________
War is over---if you want it.

P Low Low P Studio SMALL PARCEL SOLUTIONS: Homes & shops of distinction, with low prim-counts, surprisingly low prices!
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
08-05-2009 18:02
check the link in my signature below.
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
1 2