Multi Channel Listen
|
|
Gorge Go
Registered User
Join date: 7 Dec 2006
Posts: 5
|
05-15-2007 18:03
How do you get a script to listen on more than one channel while using only on llListen( ,"","",""  ; ? Examp: Listen on channels 0 to 20
|
|
Max Pitre
Registered User
Join date: 19 Jul 2006
Posts: 370
|
05-15-2007 18:14
integer lm=1; default { state_entry() { llListen(lm,"","",""); llListen(lm+1,"","",""); llListen(lm+2,"","",""); llListen(lm+3,"","",""); llListen(lm+4,"","",""); llListen(lm+5,"","",""); llListen(lm+6,"","",""); llListen(lm+7,"","",""); llListen(lm+8,"","",""); llListen(lm+9,"","",""); llListen(lm+10,"","",""); llListen(lm+11,"","",""); llListen(lm+12,"","",""); llListen(lm+13,"","",""); llListen(lm+14,"","",""); llListen(lm+15,"","",""); llListen(lm+16,"","",""); llListen(lm+17,"","",""); llListen(lm+18,"","",""); llListen(lm+19,"","",""); llListen(lm+20,"","",""); }
listen(integer channel,string name,key id,string message) { llOwnerSay(message + " said on channel "+ (string)channel); } }
|
|
Phoenix Ristow
Registered User
Join date: 11 Sep 2006
Posts: 9
|
Cleaned Up Code Alternative
05-16-2007 11:24
integer start_Channel =0; integer end_Channel = 20; default { state_entry() { integer x; for (x = start_Channel; x < end_Channel + 1;x++) { llListen(x,"","",""  ; } } listen(integer channel,string name,key id,string message) { llOwnerSay(message + " said on channel "+ (string)channel); } }
|
|
Gorge Go
Registered User
Join date: 7 Dec 2006
Posts: 5
|
05-16-2007 16:54
Thanks.
|
|
Sys Slade
Registered User
Join date: 15 Feb 2007
Posts: 626
|
05-17-2007 03:34
Is there a specific need to listen on 20 channels? Listeners add lag, and open listeners on channel 0 are the worst type. Pretty much anything that can be done with 20 channels can be done with 1 if you code it properly.
_____________________
Send me the last 4 digits of a valid SSN, I'll verify you are who you say you are, even if you aren't.
|
|
Rumbeard Chowderhead
Registered User
Join date: 9 Apr 2006
Posts: 7
|
05-17-2007 04:46
the original poster asked for only one listen. both those replies open multiple listens. both of those simply start 21 listens (0 through 20). the best one can do is have one listen cycle through the channels if you only truly want one listen. I'm not in world so excuse possible errors but I don't see any off hand. ////////////////////////////////////////// integer ear; integer interval = 3;//how often channel changes integer x; integer first_channel = 0; integer last_channel = 19; default { state_entry() { llSetTimerEvent(interval) } timer() { llListenRemove(ear); ear = llListen(x,"","",""  ; if(x<last_channel)x+=1; else x = first_channel; } listen(integer channel,string name,key id,string message) { llOwnerSay(message + " said on channel "+ (string)channel); } }
|
|
Pip Helios
Registered User
Join date: 29 Sep 2006
Posts: 22
|
05-18-2007 06:43
Just making a bit versitile, oh and I believe this does only use one listen since it cycles it. (if I'm wrong I'de love to know, I'll have some codes to change. Hate unesseray lag) list channels = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]; integer on; default { touch(integer num_detected) { if (on) { llSetTimerEvent(0); on = !on; }
else { llSetTimerEvent(.5); on = !on; } }
timer() { integer x; for (x = 0; x < llGetListLength(channels); x++) { llListen(llList2Integer(channels, x),"","",""); } llSetTimerEvent(.5); }
listen(integer channel,string name,key id,string message) { llOwnerSay(message + " said on channel "+ (string)channel); } }
Now given, I did this off the top of my head so no promises that you wont need to debug, benefit here is that you aren't limited to only a set of channels, you could listen to say channel 1,2,3,44,87,23048573,666.
|
|
Rumbeard Chowderhead
Registered User
Join date: 9 Apr 2006
Posts: 7
|
05-18-2007 08:02
in order for a single listen to cycle it must be declared as an integer as in the code in my example. if you do not declare it as an integer each call to listen opens a new one without closing the previous.
|
|
Sys Slade
Registered User
Join date: 15 Feb 2007
Posts: 626
|
05-18-2007 10:18
Yep, you have to use llListenRemove to avoid having more than one open at once.
_____________________
Send me the last 4 digits of a valid SSN, I'll verify you are who you say you are, even if you aren't.
|
|
Ralph Doctorow
Registered User
Join date: 16 Oct 2005
Posts: 560
|
05-18-2007 10:45
I'm not sure what the point to cycling through multiple channels with one listen would be though unless you knew that whatever you were listening for would recur at some rate and you kept the listen open for that period. If you aren't listening when a chat occurs you won't get it.
|
|
Pip Helios
Registered User
Join date: 29 Sep 2006
Posts: 22
|
05-18-2007 14:08
From: Rumbeard Chowderhead in order for a single listen to cycle it must be declared as an integer as in the code in my example. if you do not declare it as an integer each call to listen opens a new one without closing the previous. Hmm interesting, unfortionately I still need to keep multiple listeners up but it's still good to know, i'll take it out of the timer then on my scripts though I still want the for loop to make sure the entire list is initialized, it's just a shame I can't have a single cycling listener and need to keep 128 open instead. The least I can say is I don't use channel 0 for obvious reasons.
|