Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Too Many Listens

Jade Bard
Registered User
Join date: 7 Jul 2004
Posts: 106
05-20-2005 17:51
I'm making a game that uses dialog boxes.
And i'm wondering why, i'm getting the error
Script run-time error
Too Many Listens

Now does everytime a dialog box is sent, a new listen started?
I'm so sure i made it close no matter what...
What if the person choose to say ignore... what then?
How do i deal with that?

Thank you to anyone who can help me.
Eggy Lippmann
Wiktator
Join date: 1 May 2003
Posts: 7,939
05-20-2005 18:26
Here's a vague architectural outline for a touch activated dialog.
CODE

integer gListener;

default
{

touch_start()
{
gListener=llListen();
llDialog();
}


listen()
{
llListenRemove(gListener);
//do your thing
}

}
Eggy Lippmann
Wiktator
Join date: 1 May 2003
Posts: 7,939
05-20-2005 18:32
Here's a slightly better version, using states - changing states removes all listeners.
This prevents more than one dialog to spawn if you touch the object more than once - changing states clears the event queue.
CODE


string gMessage;

default
{

touch_start()
{
llListen();
llDialog();
}

listen(integer channel, string name, key k, string message)
{
gMessage=message;
state handle_dialog;
}

}

state handle_dialog
{

state_entry()
{
//do your thing
state default;
}

}
Eggy Lippmann
Wiktator
Join date: 1 May 2003
Posts: 7,939
05-20-2005 18:36
I forgot to add, your error is because a script can only have up to 64 listeners at any one time. And that's way more than you will ever need.
Helpful links:

http://secondlife.com/badgeo/wakka.php?wakka=llListen
http://secondlife.com/badgeo/wakka.php?wakka=llListenRemove
http://secondlife.com/badgeo/wakka.php?wakka=listen
http://secondlife.com/badgeo/wakka.php?wakka=llDialog
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
05-20-2005 23:07
state changes are another way of cleaning up listens.
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey
Keknehv Psaltery
Hacker
Join date: 11 Apr 2005
Posts: 1,185
05-21-2005 07:03
Ugh, this is annoying.

When you post scripts, PLEASE use the tags PHP and /PHP, instead of the tags CODE, or even worse, NOTHING. ( Quote this reply to look at it ). In fact, if you have Enhanced mode on in your preferences, there's a button that will let you select entire chunks of code to surround with the php brackets.

For example, here's eggy's code, nicely formatted.

Code shard 1:
CODE

default
{
touch_start()
{
llListen();
llDialog();
state handle_dialog;
}
}

state handle_dialog
{
listen()
{
//do your thing
state default;
}
}


Code shard 2:
CODE

integer gListener;

default
{
touch_start()
{
gListener=llListen();
llDialog();
}

listen()
{
llListenRemove(gListener);
//do your thing
}
}
Jon Marlin
Builder, Coder, RL & SL
Join date: 10 Mar 2005
Posts: 297
05-21-2005 07:14
From: Strife Onizuka
state changes are another way of cleaning up listens.


Are you sure about this? I'm pretty sure in my code I switch states without re-running llListen, and my listen event still works in the other states...

I think the correct way to handle this is to hold on to the listener in a global, and remove it when you are done.

- Jon
Ace Cassidy
Resident Bohemian
Join date: 5 Apr 2004
Posts: 1,228
05-21-2005 07:27
From: Jon Marlin
Are you sure about this? I'm pretty sure in my code I switch states without re-running llListen, and my listen event still works in the other states...

I think the correct way to handle this is to hold on to the listener in a global, and remove it when you are done.

- Jon


Strife is correct (how dare you question the great Samurai?). Listens are deleted on any state change.

- Ace
_____________________
"Free your mind, and your ass will follow" - George Clinton
Zalandria Zaius
Registered User
Join date: 17 Jan 2004
Posts: 277
hmm maybe just to many in the area
05-21-2005 08:38
I wonder if there are just to many in the area..

If your in an area with lots of pose balls that might be the answer..
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
05-21-2005 09:15
eggy's two state script won't work because when the state changes the listen will (should) be removed automaticly, along with timers and sensor repeats. Oh and the event queue is also cleared.
CODE

integer w;

default
{
touch_start(integer a)
{
key b = llDetectedKey(0);
a = llListen(-1,"",b,"");
llListenRemove(w);
w = a;
llDialog(b, "Choose your weapon", ["Katana", "Wakizashi","Yumi","Naginata","Tanegashima"], -1);
llSetTimerEvent(120.0);
}
listen(integer a, string b, key c, string d)
{
llSay(-2, "equip-"+d);
llListenRemove(w);
}
}


I don't use lettered variables heavily in my code. w is the only letter i will use for a global and only for listen handles.
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey
Eggy Lippmann
Wiktator
Join date: 1 May 2003
Posts: 7,939
05-21-2005 09:17
No, like I said on my previous post, they are limited on a per-script basis.
Also, Jon, if you're really seeing that kind of behavior please file a bug report!
Eggy Lippmann
Wiktator
Join date: 1 May 2003
Posts: 7,939
05-21-2005 09:20
From: Strife Onizuka
eggy's two state script won't work because when the state changes the listen will (should) be removed automaticly, along with timers and sensor repeats. Oh and the event queue is also cleared.

Yeah, that ought to teach me how to type code into the forums. Anyway, the general concept is sound even if the code is wrong - if you want to avoid further touches you have to remove the touch handle and clear the queue, by changing states. I will ammend the pseudo-code snippet.