a script to listen on multiple channels

Dale Innis daleinnisemail at gmail.com
Mon Mar 22 10:05:14 PDT 2010

Welcome to the wonders of single-threaded event-driven code.  :)

That program will never see a response; because if it's llSleep()ing
inside that for-loop, the listen() event will never fire, and so it
will never notice any response.  In general, if the sim is inside your
code somewhere (like in the llSleep()), it can never also be in your
code somewhere else (like the listen() event).

It's very easy to make this mistake if you're used to multi-threaded
event code, because there something can happen in thread B while
thread A is sleeping.  But that's not the case in LSL.

(I've found that a good rule of thumb is that if you're using
llSleep() instead of llSetTimerEvent() there's a good chance you're
Doing It Wrong, unless you really do want to impose a known delay
between two inline actions, without caring what's going on in the
outside world at all.)

I'm also sort of unclear on the concept of first listening on a bunch
of channels (no more than 16 at once, remember), and then only
continuing to listen to the ones that you've heard something on; the
result would seem to be that you'll be listening on a random set of
channels, depending on exactly who happened to be talking where when
you first listened.  But whatever works.  :)

(I also don't understand the suggestion that saying random stuff on a
whole bunch of channels would cause any listeners to run out of memory
("stack-heap"); presumably if they hear a message that they don't
understand they'll just ignore it, rather than for some reason filling
up memory...)

-- Dale

On Mon, Mar 22, 2010 at 12:21 PM, Jonathan Irvin <djfoxyslpr at gmail.com> wrote:
> Yes...I know listen() is an event, that is static.
> What I'm talking about is this...
> for(i = 100; i; i++){
> ...
> //Create a listen handle
> //Open a channel
> //Wait for a response, eg llSleep()
> ...
> }
> listen(...){
> if (no response){
> do nothing;
> }
> else{
> add channel to list to be rechecked for other comms on the next loop
> }

More information about the secondlifescripters mailing list