Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Sound problem with sliding door

Ponsonby Low
Unregistered User
Join date: 21 May 2008
Posts: 1,893
08-05-2009 13:10
I'm having trouble getting this thread to post, so I'll try posting without the message, and putting the message in another post:
_____________________
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 13:11
Okay, here's the actual problem:

I've been successfully doing some modification to existing scripts and in that way learning some of the basics--I'm aware that the brackets and semi-colons have to be in their proper places, for instance. I can make basic changes such as having a door scripted to slide sideways, slide up, instead. (I do know that this is baby-stuff!)

One of the most confusing things that I'm trying to figure out is that there are sometimes several ways to do the same thing (e.g. cause a door to slide open or make a sound play)---and that they can't be mixed and matched.

I'm hoping someone can tell me where I'm going wrong with getting a creaking sound to play when a door slides open. The sound (creak1.wav) DOES play when I hit the reset button, so...it is in there, somewhere. But it doesn't play as the door goes up and down.

I've tried fixing this by looking at a rotate-open script that I did successfully modify with the creak1.wav sound---that one works perfectly, creaking when the door opens and when it closes. But putting what works in the rotate door script into the sliding door script, isn't working.

Here's the sliding door script with my modifications:

.......................................................................
_____________________
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 13:12
This is very weird---I know the Forums filter disallows certain combinations of characters, but....don't people post scripts all the time, here?

I get the You Broke the Internet message each time I try to post it.

Maybe I can post a few lines at a time:


.......................................................................


[Rolig's suggestion worked, and the entire script is posted below.]
_____________________
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 13:14
continued:

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

close()
{
llSetTimerEvent(0);
slide(pos);
llSetPos(pos);
llSetRot(rot);
open = FALSE;
}
_____________________
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 13:18
continued:

...............................................
I can't get any of the rest to post. I tried removing the word "d_fault", and the word "ent_y" to see if they might be the problem.....none of the other words look to be the likely culprits.

I'll keep trying---I'd really like some advice!
_____________________
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!
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
08-05-2009 13:29
Be sure that (a) you are not posting with the Enhanced editor and (b) you have a space after every "< " symbol. Avoid typing the word "from" after the word "select." And curse a lot.
_____________________
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 13:31
trying again to post the remainder of the script:

.........................

default
{
_____________________
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 13:32
state_entry()
{
_____________________
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 13:33
[I'm sorry to be making all these posts but for whatever reason I can't get more than a couple of lines to post.]
......................

llTriggerSound(close_sound, 0.6);
_____________________
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 13:34
pos = llGetPos();
rot = llGetRot();
_____________________
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 13:36
From: Rolig Loon
Be sure that (a) you are not posting with the Enhanced editor and (b) you have a space after every "< " symbol. Avoid typing the word "from" after the word "select." And curse a lot.



Especially the last! But thanks--I did know about no Enhanced, but hadn't tried the other things.

I'll try putting the rest of the script--I've now put spaces after the less-than symbol:

.....................................
That did work, and just below I've posted the entire thing.
_____________________
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 13:43
I'll try posting the entire thing again, with a space after the less-than sign:

// 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.0; // 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 = 15; // seconds to stay open
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 )
{
npos += delta;
llSetPos( npos );
}
llSetPos(tgt);
}

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


default
{
state_entry()
{
llTriggerSound(close_sound, 0.6);
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;
}


}

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!
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
08-05-2009 13:47
OK... two things..... First, put llPreloadSound(name of sound file goes here) statements for your two sound files in the state_entry event in place of your llTriggerSound statement. If the sounds aren't preloaded, then you may have a big delay before you hear them. Then, I would suggest putting llPlaySound statements in your slide function, using a global flag to switch between your "open" and "closed" sounds, as appropriate.

BTW, when you post a script, put a
CODE
marker at the start of your script and a at the end. That will preserve your indentations and make the script lots eaier to read. :)
_____________________
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 13:49
Many thanks---If I can get inworld now (we've had storms and my internet is fragile) I will try these suggestions.

(and will do the php thing in future. ^_^)
_____________________
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 13:55
From: Rolig Loon
OK... two things..... First, put llPreloadSound(name of sound file goes here) statements for your two sound files in the state_entry event in place of your llTriggerSound statement.
That's less useful than it sounds. llPreloadSound only has an effect on avatars in earshot when you run it. It's basically the same as doing an llPlaySound with mute on, to get the viewers to download the sound but not play it.

It's worthwhile preloading the "closed" sound after playing the "open" sound to cut down on the delay before it plays, but unless you do something like running a sensor for nearby avatars and calling llPreloadSound when one comes into range you can't depend on the "open" sound getting preloaded for anyone but yourself.
_____________________
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 14:19
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.)
_____________________
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 14:21
Is there any lead time in the sound sample? What does its envelope look like?
_____________________
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 14:21
From: Argent Stonecutter
That's less useful than it sounds. llPreloadSound only has an effect on avatars in earshot when you run it. It's basically the same as doing an llPlaySound with mute on, to get the viewers to download the sound but not play it.

It's worthwhile preloading the "closed" sound after playing the "open" sound to cut down on the delay before it plays, but unless you do something like running a sensor for nearby avatars and calling llPreloadSound when one comes into range you can't depend on the "open" sound getting preloaded for anyone but yourself.



Any suggestion on the basic problem (to get the sound to play during the actual open and 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 14:24
From: Argent Stonecutter
Is there any lead time in the sound sample? What does its envelope look like?



Yikes, my ignorance....'envelope' is unknown to me.

Here's the sound's name and UUID:

creak1.wav 9f989554-e5d4-5c9b-d7a9-73485d6e76ff


It sounds to me (when I choose Play on it, in Inventory) as though it has little or no lead time (but 'sounds like' is probably not helpful).
_____________________
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 14:24
If there is a fixed delay before the sound starts, indicating a lead-in in the sample, either trim the sample to a zero crossing and re-upload it, or play the sound, sleep a second, start the opening process.

If the problem is that the first time you play it, it's delayed because it hasn't downloaded yet, then you may need to preload the sound, wait a second, then play the sound and start the opening process.
_____________________
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
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
08-05-2009 14:26
From: Ponsonby Low
Yikes, my ignorance....'envelope' is unknown to me.
Here's the sound envelope of a stick striking a cymbal. Notice that there is a quiet period before the sound starts, that's the lead time:

_____________________
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 14:30
From: Argent Stonecutter
Here's the sound envelope of a stick striking a cymbal. Notice that there is a quiet period before the sound starts, that's the lead time:



Oh, I see.

I suppose I could save it to my harddrive and open it in Audacity and look at it, but...from the way the sound plays when I click on it in Inventory, this is NOT the problem. (I'm guessing we would see little or no quiet period.)

And as mentioned, I HAVE successfully gotten this very sound to play in a door that works with Rotate rather than slide---the sound begins at the moment the door starts to move, both to open and to close.

Also as mentioned I used bits from the successful door-rotates script to try to modify this silent door-slides script....but, no luck.
_____________________
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 14:35
Are you sure that script is what you're using? Because you're not playing the sounds at all in it.
_____________________
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 14:46
Since I made the change Rolig suggested, the sound does play about half a second after the door slides up.

(I know what you mean, though. This is what's so difficult about scripting, I think: some scripts will have a line in an event handler that clearly triggers the sound. And some don't, yet they still play the sound.)
_____________________
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 14:56
From: Ponsonby Low
I know what you mean, though. This is what's so difficult about scripting, I think: some scripts will have a line in an event handler that clearly triggers the sound. And some don't, yet they still play the sound.
Wot?

That makes no sense at all.

What does your script look like now?
_____________________
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
1 2