childhoodbestfriend489 Posted April 4, 2021 Share Posted April 4, 2021 I expect that it will show textbox for typing message for every choosen channel. But It is doing it only for 1. integer schannel = 40; integer tuned = 1; integer listener; list buttons; string mode; default { touch_start(integer num) { if (llDetectedKey(0) == llGetOwner()) { llListen(schannel,"",llGetOwner(),""); if(mode != "mute") { buttons = ["Message","Channel","Mute"]; llDialog(llGetOwner(),"Current channel: "+(string)tuned+"\nChoose an option:",buttons,schannel); } else if(mode == "mute") { buttons = ["Message","Channel","Unmute"]; llDialog(llGetOwner(),"Current channel: "+(string)tuned+"\nChoose an option:",buttons,schannel); } } else { llInstantMessage(llDetectedKey(0),"Only owner has access to it."); } } listen(integer channel, string name, key id, string msg) { if (channel == schannel && id == llGetOwner()) { if (msg == "Channel") { mode = "setchan"; llTextBox(llGetOwner(),"Current channel: "+(string)tuned+"\nTune into channel:",schannel); } else if (mode == "setchan" && msg != "Channel") { tuned = (integer)msg; } else if (msg == "Message") { mode = "send"; llTextBox(llGetOwner(),"Current channel: "+(string)tuned+"\nType your message:",schannel); } else if (mode == "send" && msg != "Message") { llSay(tuned,msg); llInstantMessage(llGetOwner(),"\nchannel: "+(string)tuned+"\nsecondlife:///app/agent/"+(string)llGetOwner()+"/about(you): "+msg); } else if (msg == "Mute") { mode = "mute"; llListenRemove(listener); } else if (msg == "Unmute") { mode = ""; listener = llListen(tuned,"","",""); } } if (channel == tuned && id != llGetOwner()) { llInstantMessage(llGetOwner(),"\nchannel: "+(string)tuned+"\nsecondlife:///app/agent/"+(string)id+"/about: "+msg); } } } Link to comment Share on other sites More sharing options...
Quistess Alpha Posted April 4, 2021 Share Posted April 4, 2021 (edited) NVM might have misunderstood the intent of the code. Edited April 4, 2021 by Quistessa Link to comment Share on other sites More sharing options...
childhoodbestfriend489 Posted April 4, 2021 Author Share Posted April 4, 2021 NVM means? Link to comment Share on other sites More sharing options...
Profaitchikenz Haiku Posted April 4, 2021 Share Posted April 4, 2021 (edited) In order for your idea to work there has to be a place in the listen where a string of digits is detected and converted into an integer, and then used as the new listen channel, but the only place I can see where that ought to happen is inside an if(msg == "Unmute") block, so it seems that you have to first of all give it a number and then give it an Unmute command to make it work? I have to say that the indentation used is making it very tricky to try and spot where things are happening and under what conditions. ETA I have also just noticed that you never reassign schannel, so that even if you do manage to open a new listen using the value assigned to tuned, the initial test "if(channel == schannel" is going to skip by whatever is being said on the new channel. Edited April 4, 2021 by Profaitchikenz Haiku thought better of something Link to comment Share on other sites More sharing options...
Profaitchikenz Haiku Posted April 4, 2021 Share Posted April 4, 2021 2 minutes ago, childhoodbestfriend489 said: NVM means? Never Mind Link to comment Share on other sites More sharing options...
childhoodbestfriend489 Posted April 4, 2021 Author Share Posted April 4, 2021 I tried keeping message sending related terms before the channel tuning term starts. Now it's working. I don't know why. Link to comment Share on other sites More sharing options...
Profaitchikenz Haiku Posted April 4, 2021 Share Posted April 4, 2021 I never quite know which is worse, doing the wrong things for the right reasons, or the right things for the wrong reasons. If you've re-arranged things inside the listen event then you have most likely moved the specific lines that open the new listen up into a higher level block so that they are now directly accessible to the string of ifs. Or, you've moved some of the statements out of the block controlled by (if channel == schannel) so that they are now being processed on the new channel number. If you've saved the evolving versions of your script you can take the most recent and the preceding versions as files into the Context editor and use the compare option to do a side by side comparison to see where the changes are and hence work out why it now does what you want it to. 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