Jump to content

Door Sounds


ElPancho
 Share

You are about to reply to a thread that has been inactive for 3806 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

 

Heelo all :)

How do I add "open" and "close" sounds (on touch) to the following script please? I already have the sounds :)

 

 //-- 90 degrees around z axis, use - 90 to reverse direction
vector vDegSwing = <0, 0, -90>;
rotation vRotSwing;
//-- 10.0 seconds till auto close
float vFltTmt = 5.0;
float vFltOpn;

uDoor(){
  llSetLocalRot( (vRotSwing = ZERO_ROTATION / vRotSwing) * llGetLocalRot() );
  llSetTimerEvent( (vFltOpn = (float)(!((integer)vFltOpn)) * vFltTmt) );
  //-- small hack to get around logical not with floats
}

default{
  state_entry(){
    vRotSwing = llEuler2Rot( vDegSwing * DEG_TO_RAD ); // convert to rotation
  }
  
  touch_start( integer vIntNull ){
    uDoor();
  }
  
  timer(){
    if (vFltOpn){
      uDoor();
    }
  }
}

 

Link to comment
Share on other sites

 //-- 90 degrees around z axis, use - 90 to reverse directionvector vDegSwing = <0, 0, -90>;rotation vRotSwing;//-- 10.0 seconds till auto closefloat vFltTmt = 5.0;float vFltOpn;float Volume = 1;uDoor(){  llSetLocalRot( (vRotSwing = ZERO_ROTATION / vRotSwing) * llGetLocalRot() );  llSetTimerEvent( (vFltOpn = (float)(!((integer)vFltOpn)) * vFltTmt) ); // vFltOpn will flip between zero and vFltTmt  if(vFltOpn){      llPlaySound("DoorOpen",Volume);  }  else {      llPlaySound("DoorClose",Volume);  }}default{  state_entry(){    vRotSwing = llEuler2Rot( vDegSwing * DEG_TO_RAD ); // convert to rotation  }    touch_start( integer vIntNull ){    uDoor();  }    timer(){    if (vFltOpn){      uDoor();    }  }}

You will need two sounds, called "DoorOpen" and "DoorClose" in the contents folder of the prim (door) where the script resides.

Volume controls the loudness of the played sounds, 1 = max, 0 = off.

It appears your door will open/close very quickly, as it makes only one call to llSetLocalRot() to do the entire 90 degree rotation. Your door sounds will have to be very short.

  • Like 1
Link to comment
Share on other sites

You've misunderstood the purpose of this forum.  This is a place for scripters to learn from each other, to trade ideas and fret about scripts that aren't working quite right.  If you are working on a script and are looking for help getting past a rough spot, you can usually get another scripter to offer a suggestion, as Steph did.  If you are looking for someone to write a script for you, however, you should post your request in the InWorld Employment forum.

Link to comment
Share on other sites

Rolig Loon, sorry you are making  fuss for nothing. I got here because I was trying to make that myself and found difficulties so I thought searching for help. Of course I could hire someone or I could have gotten the 5th doors script on MarketPlace for another try so after a research I saw someone making the same question here to a different type of door script. He was kindly helped and thought I'd find the same help. Were we posting at the wrong forum? Maybe. But nothing like a nice way of saying things to people. Specially if they never posted before. Anyway, thanks for your input. Sort of passive aggressive but valuable for forum newbies. Peace.

 

Link to comment
Share on other sites

No problem.  And no fuss either.  I just wanted to be sure that you knew what  the forum was for.  Please don't hesitate to come back if you do want help with a script that you're writing.  We're a pretty helpful bunch generally.

Incidentally, that little door script of Void's is nice, but I'm not sure why she bothered with the trickiness in setting the timer.  Instead of writing

llSetTimerEvent( (vFltOpn = (float)(!((integer)vFltOpn)) * vFltTmt) );

she could have just defined vFltOpn as an integer instead of a float and written

llSetTimerEvent( (vFltOpn = !vFltOpn) * vFltTmt);

 

 

Link to comment
Share on other sites

I suspect it's one of Void's micro-optimisations, since, in general, it's better to feed llSetTimerEvent() a float than to have it cast an integer as a float each time (and, of course, if you really, really want to have the door close after 5.5 seconds, you have to cast it as a float for llSetTimerEvent()).

I'm not sure how much difference it makes in the great scheme of things, but who am I to argue with Void about scripting?

Link to comment
Share on other sites

I don't get why people get so aggressive when a newbie makes a question if it's in the wrong forum. Less energy spent just redirecting the person to the right one. Anyway, not here to start a war, I just made a question, you replied and I asked you to be more specific (see the smile in the end of my answer, that means I was being friendly although I stated if I knew what to do I'd not be searching for help) then I got my answer from someone who saw what I meant, simple as that. Yes, that was my first question ever and probably the last. Don't need to be bashed if I make a mistake of posting a question at the wrong forum. Anyway, I'm off here, as internet arguing isn't my cup of tea. Peace to you too.

 

Link to comment
Share on other sites

I thought the logic of that script was rather opaque. In my world (small microcontrollers), you'd not code a binary state in a float, as you usually don't have floating point hardware. You'd also avoid multiplies, as you often don't even have hardware multiply. So I'd have coded the on/off state in an integer (or a bit field, if the underlying processor had bit test instructions and RAM was tight) named "Open" and passed constants to the timer, depending on the state of "Open".

But Void is Void.

;-)

Link to comment
Share on other sites


ElPancho wrote:

erm thanks but f I knew what that is I'd not be here, be more specific please
:)

Use llTriggerSound(string sound, float volume) is as about as specific as you can get, learning how to read that statement would help you out a lot if you want to learn to edit scripts.

llTriggerSound() is a function: 

http://wiki.secondlife.com/wiki/LlTriggerSound

http://wiki.secondlife.com/wiki/Category:LSL_Functions

 

(string sound, float volume) are the parameters and data types for the function, a string and float are types: 

http://wiki.secondlife.com/wiki/Category:LSL_Types 

http://wiki.secondlife.com/wiki/Category:LSL_Float

http://wiki.secondlife.com/wiki/Category:LSL_String

 

The LSL tutorials would be an other good place to get started

http://wiki.secondlife.com/wiki/Category:LSL_Tutorials

 

To learn how to edit scripts in LSL you don't have to know every thing about LSL, but you do need to know how to reference it.

Functions | Events | Types | Operators | Constants | Flow Control

 

 

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

Yeah, it's all very possible.

The lsl function to look for in your script is llPlaySound() or llTriggerSound() (your script might use either).

The syntax (same for both) is llPlaySound(sound, volume); where sound is the name of the sound or its UUID (both need to be in "double quotes").  If you put in the name of the sound, then the sound needs to be in the same prim as the script.   If you put in the UUID, then you don't need to add the sound file to the prim.  

Volume in both cases is a float between 0.0 and 1.0.  I'd use 1.0, since sounds are usually pretty much inaudible otherwise.

 

  • Confused 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3806 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...