Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Has my object has instantiated multiple listens?

Zen Zeddmore
3dprinter Enthusiast
Join date: 31 Jul 2006
Posts: 604
09-08-2007 16:50
Is there anyway to determine if my object has instantiated multiple listens.
IOW, i'm uncertain if in the midst on numerous test scripts recompiles and resets et al.
might i have hundreds of listen events going on and causing lag?
would the only way to be certain to recreate a scriptless version of the object and introduce the ( now final version ) script and run it once.
_____________________
A kilogram of programmable nanobots can lower the certainty of both death AND taxes.
Jotheph Nemeth
Registered User
Join date: 9 Aug 2007
Posts: 142
09-08-2007 17:09
From: Zen Zeddmore
Is there anyway to determine if my object has instantiated multiple listens.
IOW, i'm uncertain if in the midst on numerous test scripts recompiles and resets et al.
might i have hundreds of listen events going on and causing lag?
would the only way to be certain to recreate a scriptless version of the object and introduce the ( now final version ) script and run it once.



No. If you change state, such as by recompiling or resetting, any open listens are closed.

Theoretically anyway. I wouldn't be surprised if the devs left crud hanging on the server even though the listen isn't active.
Zen Zeddmore
3dprinter Enthusiast
Join date: 31 Jul 2006
Posts: 604
09-08-2007 19:19
thanks.
_____________________
A kilogram of programmable nanobots can lower the certainty of both death AND taxes.
Bloodsong Termagant
Manic Artist
Join date: 22 Jan 2007
Posts: 615
09-10-2007 08:04
hmm.... are you sure?

i've heard that listeners are messy and don't clean up properly. but that might just be when the script is running, not when compiling.

however, you CAN kill listeners on startup. you can call the llListenRemove even on a listener that doesnt exist, because that won't throw an error. if you want to be more safe than sorry ;)

for any tuning in who don't know how to do that, you just need a global int to track the listener:

integer listener;


//starting the listener:
listener = llListen(....);

//killing the listener:
llListenRemove(listener);
_____________________
Why Johnny Can't Rotate:
http://forums.secondlife.com/showthread.php?t=94705
Zen Zeddmore
3dprinter Enthusiast
Join date: 31 Jul 2006
Posts: 604
09-10-2007 08:29
mayby i should remake to be certain.

... so this code is allowed?

[begin code]

integer listener;

//killing the listener:
llListenRemove(listener);

//starting the listener:
listener = llListen(....);

[end code]

but how does this know which chanell to stop listening on?
er nevermind you can only hve one chanell per variable , right?
_____________________
A kilogram of programmable nanobots can lower the certainty of both death AND taxes.
Lear Cale
wordy bugger
Join date: 22 Aug 2007
Posts: 3,569
09-10-2007 12:23
Changing state cancels all listens. Try it and see!

Resetting a script cancels all listens.

Cancelling 0 or a handle left over from after a state change is a waste. It's not a good idea.
Lear Cale
wordy bugger
Join date: 22 Aug 2007
Posts: 3,569
09-10-2007 12:36
Zen, if you intentionally have multiple listens going and want to be able to cancel certain ones, then you have to save the handle separately for each listen you intend to cancel.

I have used code like this, in a relatively complex script where I needed to cancel a set of listens at a certain point. (BTW, put your code between "
CODE
" and "[/php ]" tags, without the space after php.  This feature is turned off right now, but someday they should turn it back on,  Meanwhile, you can look at someone's code with indentation, by hitting the "Quote" button on their post.

CODE

list Listens;

...
Listens += [llListen(...)];

...
Listens += [llListen(...)];

... etc ...

// Clean up: cancel all our listens
while (llGetListLength(Listens) != 0) {
llCancelListen(llList2Integer(Listens, 0));
Listens = llListDeleteSubList(Listens, 0, 0);
}


Note that this isn't the most memory-efficienty way to do this, it's just the simplest and clearest. It keeps a list "Listens", and each time a new listen is started, appends the new listen handle to the list. To cleanup, as long as the list is not empty, it cancels the first listen handle in the list.

Note that there could be any number of other listens where we didn't save the handle in the list, and those would be unaffected by our cleanup. Or we could keep any number of lists of listens, and clean up different lists for different cases. Or you might not need lists at all, but a different handle variable for each listen you intend to cancel.

Simplest, though, is to just change state, which cancels all listens.
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
09-10-2007 23:52
Note that scripts are limited to 64 simultaneous listens.

Trying to add more would just return an error message.