Rafael Tower Posted February 28, 2016 Share Posted February 28, 2016 // www.lsleditor.org by Alphons van der Heijden (SL: Alphons Jano) integer listener; integer channel = 7; string msg = "play"; string soundName = "sound"; default { state_entry() { listener = llListen(channel,"","",msg); } listen(integer channel, string name, key id, string message) { llPlaySound(soundName,1.0); } }This is from the archive. But how to restric this script to owner only. (The sound will play only when something that belongs to owner emits the message. Link to comment Share on other sites More sharing options...
steph Arnott Posted February 28, 2016 Share Posted February 28, 2016 // www.lsleditor.org by Alphons van der Heijden (SL: Alphons Jano) integer listener; integer channel = 7; string msg = "play"; string soundName = "sound"; key ownerid; default { state_entry() { ownerid = llGetOwner();//just the way i prefer listener = llListen(channel, "", ownerid, ""); //listener = llListen(channel, "", llGetOwner(), "");// can do it this way also } listen(integer channel, string name, key id, string message) { llPlaySound(soundName,1.0); } } Link to comment Share on other sites More sharing options...
Rafael Tower Posted February 28, 2016 Author Share Posted February 28, 2016 It doesn't play any sound now. I'm confused ... Link to comment Share on other sites More sharing options...
Rafael Tower Posted February 28, 2016 Author Share Posted February 28, 2016 and when I use this // www.lsleditor.org by Alphons van der Heijden (SL: Alphons Jano)integer listener;integer channel = 7;string msg = "play";string soundName = "sound";key ownerid;default{ state_entry() { listener = llListen(channel, "", ownerid, ""); //listener = llListen(channel, "", llGetOwner(), "");// can do it this way also } listen(integer channel, string name, key id, string message) { llPlaySound(soundName,1.0); }} It still plays a sound but from people's objects too. Link to comment Share on other sites More sharing options...
steph Arnott Posted February 28, 2016 Share Posted February 28, 2016 sound needs tio be called by its file name thats in the contents, Change this "sound" to what the file is named. Link to comment Share on other sites More sharing options...
Rafael Tower Posted February 28, 2016 Author Share Posted February 28, 2016 Yes it has be done and renamed Link to comment Share on other sites More sharing options...
steph Arnott Posted February 28, 2016 Share Posted February 28, 2016 You be better using llTriggerSound "It still plays a sound but from people's objects too." yea ok. Link to comment Share on other sites More sharing options...
Rafael Tower Posted February 28, 2016 Author Share Posted February 28, 2016 And now works like a charm ! What is the difference between Playsound and triggersound ? Link to comment Share on other sites More sharing options...
Rafael Tower Posted February 28, 2016 Author Share Posted February 28, 2016 Thank you very much for your help Steph !!! Link to comment Share on other sites More sharing options...
steph Arnott Posted February 28, 2016 Share Posted February 28, 2016 Rather than rewrite read Roligs explaination https://community.secondlife.com/t5/LSL-Scripting/llPlaySound-or-llTriggerSound/td-p/2334469 Short answer is if the object is stationary use llTriggerSound else use llPlaySound if it is moveing, BTW you can limit the sound broadcast by using llTriggerSoundLimited. that will restrict the sound to a hard cut off Link to comment Share on other sites More sharing options...
Dora Gustafson Posted February 28, 2016 Share Posted February 28, 2016 Try this instead: // www.lsleditor.org by Alphons van der Heijden (SL: Alphons Jano)integer listener;integer channel = 7;string msg = "play";string soundName = "sound";default{ state_entry() { listener = llListen(channel,"","",msg); } listen(integer channel, string name, key id, string message) { if ( llGetOwnerKey( id) == llGetOwner() ) llPlaySound(soundName,1.0); }} Will only play on messages from an object with same owner :smileysurprised::smileyvery-happy: Link to comment Share on other sites More sharing options...
steph Arnott Posted February 28, 2016 Share Posted February 28, 2016 Would work either way. Link to comment Share on other sites More sharing options...
Dora Gustafson Posted February 28, 2016 Share Posted February 28, 2016 Note that if ( llGetOwnerKey( id) == llGetOwner() ) is not the same as if ( id == llGetOwner() ) :smileysurprised::smileyvery-happy: 1 Link to comment Share on other sites More sharing options...
steph Arnott Posted February 28, 2016 Share Posted February 28, 2016 The llListen is allready set to owner only communications This clearly states that limit. ownerid = llGetOwner();//just the way i prefer listener = llListen(channel, "", ownerid, ""); //listener = llListen(channel, "", llGetOwner(), "");// can do it this way also Link to comment Share on other sites More sharing options...
Dora Gustafson Posted February 28, 2016 Share Posted February 28, 2016 If llListen is filtering anything but the what is said by the owner then nothing said by objects (owned by owner or otherwise) will trigger the listen event :smileysurprised::smileyvery-happy: Link to comment Share on other sites More sharing options...
steph Arnott Posted February 28, 2016 Share Posted February 28, 2016 Which is what i allready have done, it will listen only to the UUID of the object owner, your way will listen to everything on channel 7 and then filter. Whhy use a script to filter rather than the step before that? Link to comment Share on other sites More sharing options...
Dora Gustafson Posted February 28, 2016 Share Posted February 28, 2016 Because that was what the OP asked for The op wanted his/her objects and no other objects, to trigger sound by chat :smileysurprised::smileyvery-happy: Link to comment Share on other sites More sharing options...
steph Arnott Posted February 28, 2016 Share Posted February 28, 2016 Which is what i did, so am at a loss on this one. Nothing wrong with your way, tho seems more complcated than needed, but what ever. Link to comment Share on other sites More sharing options...
Dora Gustafson Posted February 28, 2016 Share Posted February 28, 2016 When you filter for owner no messages from owner's objects will come through the filter This is what you do, so it is no wonder the OP didn't make it work :smileysurprised::smileyvery-happy: 1 Link to comment Share on other sites More sharing options...
steph Arnott Posted February 28, 2016 Share Posted February 28, 2016 This is the OPs and by agent chat on channel 7 and not by an object. " But how to restric this script to owner only. (The sound will play only when something that belongs to owner emits the message." listenHandle = llListen(0, "", llGetOwner(), ""); } listen(integer channel, string name, key id, string message) {// we filtered to only listen on channel 0// to the owner's chat in the llListen call above Link to comment Share on other sites More sharing options...
Dora Gustafson Posted February 28, 2016 Share Posted February 28, 2016 steph Arnott wrote: This is the OPs and by agent chat on channel 7 and not by an object. " But how to restric this script to owner only. (The sound will play only when something that belongs to owner emits the message." Something that belongs to the owner is an object An object and an Avatar do NOT have the same id, so when you filter for the Avatar id only, no messages with any other id comes through and nothing that belongs to the owner can trigger the sound :smileysurprised::smileyvery-happy: 1 Link to comment Share on other sites More sharing options...
steph Arnott Posted February 28, 2016 Share Posted February 28, 2016 Just ran it inworld and works just fine ADDED, Went in world with my test alt, it does not hear me. ADDED, OK "only when something that belongs to owner emits the message." i get your point, my error. Link to comment Share on other sites More sharing options...
steph Arnott Posted February 28, 2016 Share Posted February 28, 2016 Your script is correct, mine was based on the script presented. Link to comment Share on other sites More sharing options...
Dora Gustafson Posted February 28, 2016 Share Posted February 28, 2016 I'm happy we can agree on this one and happy you realize the complexity of the problem Sometimes things are not as simple as they look at first glance Scripting is tricky Keep up the good work :smileysurprised::smileyvery-happy: Link to comment Share on other sites More sharing options...
steph Arnott Posted February 28, 2016 Share Posted February 28, 2016 Say one is wrong and accepting it is more important. 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