Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Question about llListenRemove()

Tiarnalalon Sismondi
Registered User
Join date: 1 Jun 2006
Posts: 402
07-19-2006 06:51
I have a script running that is heavily menu based for different options on my ship.

All of the items work perfectly...bugs are all ironed out as far as I can tell....Except..

I decided to test the menu system itself to make sure it was *not* listening when the menu had not been called. This is in order to attempt and reduce the amount of lag generated by the script.

Basically when the owner or guest pilot(guest must be seated in the ship) touches it, it starts the listen and calls the menu. The menu breaks down to all of the different options that they have...colors, guest mode, flight modes, start/stop, help, etc, and when they reach the end of a menu tree, it performs the requested action or sends the message that causes the action, and then it has a call to llListenRemove(MENU_CHANNEL);

Now I understand that if someone clicks that Ignore button, it is not going to stop listening and I'm not sure if there's a way around that. Does the ignore button actually return a NULL_KEY or some kind of message that lets anything other than their client know that they ignored the menu?

I also tested the menu further by typing things like: "/99 Mode On" as this is the menu channel and one of the options, to see if it would do it and it did. I did this several times in fact and it never failed to keep responding to the command....even though the script clearly says

CODE
if ((message == "Mode On") && (!Guest))
{
Guest = TRUE;
llWhisper(0, "Guest Mode Initiated.");
llListenRemove(MENU_CHANNEL);
}
else if ((message == "Mode On") && (Guest))
{
llWhisper(0, "Guest Mode is already on.");
llListenRemove(MENU_CHANNEL);
}


Even if there were errant listens from ignores running....there shouldn't have been over 20 active listens running, and it never failed that every time I typed /99 Mode On, it would tell me over and over that the mode was already on just as the script says it should.

Am I just misunderstanding what this command is for? or perhaps misusing it?
Adriana Caligari
Registered User
Join date: 21 Apr 2005
Posts: 458
07-19-2006 07:04
First up

No the ignore does absolutely nothing - returns nothing !!
( bone of contention for me )

I get around that by putting in timers to time out the listen after a set time.

Second

Your llListenRemove

How are you defining the listen ?

is it :

llListen( MENU_CHANNEL,"","","" ) ;

or is it :

MENU_CHANNEL = llListen( another_channel,"","","" );


You see the llListenRemove removes the listen based on the handle ( ie the bit on the left side of the "=" )

try using :

lkey = llListen( MENU_CHANNEL,"","","" );

llListenRemove( lkey );


Hope it helps.
_____________________
Maker of quality Gadgets
Caligari Designs Store
Sirlor Stonecutter
Registered User
Join date: 13 Sep 2005
Posts: 6
07-19-2006 07:06
Ah, I've seen this problem happen many times. You are doing everything correct except for one crucial thing.

llListenRemove is not asking for a channel number. When you use the llListen function it actually acts as an integer. So when using that command you'll want to do the following.

1) define a global integer for your listen handle; eg integer listenhandle;
2) assign that integer a value; eg in state_entry { listenhandle = llListen(99,"",NULL_KEY,"";); }
3) to have it start listening issue the llListenControl function; eg llListenControl(listenhandle,TRUE);
4) shut it off when you're done; eg llListenControl(listenhandle,FALSE);

I believe that is the best way to clean up your listens. BTW Ignore does not return anything.

I hope I best answered your question
Travis Bjornson
Registered User
Join date: 25 Sep 2005
Posts: 188
07-19-2006 07:09
The ignore button doesn't return anything at all. Many people use a timeout, so that it stops listening if you don't make a choice in time.

But if you're only using one channel, then there will only be one active listen at most.
Baron Hauptmann
Just Designs / Scripter
Join date: 29 Oct 2005
Posts: 358
07-19-2006 07:56
On that note, I have a question regarding listens.

Normally, I have been coding

CODE

ListenHandle = llListen(channel, "", NULL_KEY, "");
.
.
.
.
llListenRemove(ListenHandle);


Now, this same thing gets called periodically. Would it be better to use llListenControl to turn it off and on until I am ABSOLUTELY finished with it (at least for a while)?

Thanks,
Baron H.
Sirlor Stonecutter
Registered User
Join date: 13 Sep 2005
Posts: 6
07-19-2006 08:39
llListenControl all the way dude, It's alot cleaner than any other method i believe..
Tiarnalalon Sismondi
Registered User
Join date: 1 Jun 2006
Posts: 402
07-19-2006 08:51
Thanks everyone...that confirms my suspicions about the llListenRemove() in my script.

I'll probably just use llListenControl instead from now on, but I'll just change the ListenRemove's MENU_CHANNEL to another variable that = llListen(MENU_CHANNEL, "", agentKey, "";); as this will be the easiest to replace.

I would implement the timer feature as there is already a physics watcher built in to this, however I'm already going to have to split this in to 2 or more scripts due to all the menu calls filling the memory for that script. Perhaps later as an update =)
Baron Hauptmann
Just Designs / Scripter
Join date: 29 Oct 2005
Posts: 358
07-19-2006 09:45
Thanks, as well!
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
07-19-2006 10:27
From: Baron Hauptmann
Now, this same thing gets called periodically. Would it be better to use llListenControl to turn it off and on until I am ABSOLUTELY finished with it (at least for a while)?

Probably more practical to use llListenControl() if you are using single listener with fixed channel for the whole time your script is active. Some use randomly picked channel for each communication, so have to re-build the listen anyway ^^;