ElPancho Posted November 24, 2013 Share Posted November 24, 2013 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 More sharing options...
steph Arnott Posted November 24, 2013 Share Posted November 24, 2013 Use llTriggerSound(string sound, float volume) Link to comment Share on other sites More sharing options...
ElPancho Posted November 24, 2013 Author Share Posted November 24, 2013 erm thanks but f I knew what that is I'd not be here, be more specific please Link to comment Share on other sites More sharing options...
Madelaine McMasters Posted November 25, 2013 Share Posted November 25, 2013 //-- 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. 1 Link to comment Share on other sites More sharing options...
Rolig Loon Posted November 25, 2013 Share Posted November 25, 2013 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 More sharing options...
ElPancho Posted November 25, 2013 Author Share Posted November 25, 2013 Thanks Madalaine, kindness appreciated for this forum newbie, cheers Link to comment Share on other sites More sharing options...
ElPancho Posted November 25, 2013 Author Share Posted November 25, 2013 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 More sharing options...
steph Arnott Posted November 25, 2013 Share Posted November 25, 2013 I did actually answer your question, when an event is triggered the code in that event block is executed. I assumed you were just looking for the predefined function. As for making a fuss, a mirror may help. Rolig probably answer 500 questions today and you asked one, peace goes two ways. Link to comment Share on other sites More sharing options...
Rolig Loon Posted November 25, 2013 Share Posted November 25, 2013 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 More sharing options...
Innula Zenovka Posted November 25, 2013 Share Posted November 25, 2013 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 More sharing options...
Rolig Loon Posted November 25, 2013 Share Posted November 25, 2013 Well, she already has a float there, and I doubt that multiplying a float by an integer is any slower than doing that explicit typecasting dance. I'll add that to my mental list of things that I wish I could ask Void. Link to comment Share on other sites More sharing options...
ElPancho Posted November 25, 2013 Author Share Posted November 25, 2013 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 More sharing options...
Madelaine McMasters Posted November 25, 2013 Share Posted November 25, 2013 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 More sharing options...
ElPancho Posted November 25, 2013 Author Share Posted November 25, 2013 Thanks Rolig Link to comment Share on other sites More sharing options...
steph Arnott Posted November 25, 2013 Share Posted November 25, 2013 There was no aggression, you just seem to think there is. If you want to be treated as an adult then behave like one and stop making up things that do not exist. Link to comment Share on other sites More sharing options...
ElPancho Posted November 25, 2013 Author Share Posted November 25, 2013 Hi Madalaine , I tried the script in world but it gives me some sort of error when saved: 12,5 ERROR Syntax error, would you know how to fix it? Link to comment Share on other sites More sharing options...
Madelaine McMasters Posted November 25, 2013 Share Posted November 25, 2013 Hmm, I just copied the script from my post and pasted it into a new script in a prim and it works fine, generating "Could not find sound" errors for the two missing sounds when touched, as it should until appropriately named sound files are added to the contents folder. Check your cut/paste? Link to comment Share on other sites More sharing options...
ElPancho Posted November 25, 2013 Author Share Posted November 25, 2013 lol yes, it worked now thank you Link to comment Share on other sites More sharing options...
Parrish Ashbourne Posted November 27, 2013 Share Posted November 27, 2013 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 1 Link to comment Share on other sites More sharing options...
Nio Skytower Posted January 2, 2014 Share Posted January 2, 2014 I also have a question about door sounds. If I'am building a door and using a free full perm door script with sound, how can I be able to add my own sound or can I? Some of the doors, I wish them to have a specific sound, so is that possible? Thanks. Link to comment Share on other sites More sharing options...
Innula Zenovka Posted January 2, 2014 Share Posted January 2, 2014 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. 1 Link to comment Share on other sites More sharing options...
Nio Skytower Posted January 2, 2014 Share Posted January 2, 2014 Ok, Thank You. I did not see your reply before, I thought I was in the wrong forum to ask the question. Thank You, I will try again and see if I can figure it out. Link to comment Share on other sites More sharing options...
Innula Zenovka Posted January 3, 2014 Share Posted January 3, 2014 Any problems with the script, just post here and I'll try to help. Link to comment Share on other sites More sharing options...
Recommended Posts
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