Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Nearby objects listen and respond to eachother! No! No! No!

Over Sleeper
I Dream in LSL
Join date: 12 Jan 2006
Posts: 141
04-30-2006 07:29
I have a few objects that all have the same menu. Is there a way to make each one NOT listen to eachother? When I use my menu, they ALL respond!

CODE
 llDialog(llGetOwner(),"menu",buttons,1001); 


I think it's the 1001, but not sure. I only want each object to talk to-and listen to itself. I know I can just change channels, but since this is an object I intend on distruting freely, I need it to somehow do it on its' own.

Any ideas on this?
Over Sleeper
I Dream in LSL
Join date: 12 Jan 2006
Posts: 141
04-30-2006 08:11
I changed

CODE
 llListen(1002, "", avatar, "" );

and
CODE
 llDialog(llGetOwner(),"menu",buttons,1002); 


from 1001 to 1002 and it only listened to itself...no other responses. Yay!
so at least now I know that this is the problem. How can I generate a random listen channel instead of typing it in?
Over Sleeper
I Dream in LSL
Join date: 12 Jan 2006
Posts: 141
04-30-2006 08:20
OK, I got it under control ;)

I used llFrand to generate random channel. Now works cool.
Introvert Petunia
over 2 billion posts
Join date: 11 Sep 2004
Posts: 2,065
04-30-2006 08:25
Why would you want a random channel at run-time when there are 4294967294 to choose from? Pick a random number in that range (actually -2147483647..2147483647 methinks) and the chance of it being found are 1 in 2e-10.

If you are need them to be unique, you can have a default "bootstrap" channel where the master sends a slave a new channel number (perhaps encoded with some "secret" string), but depending on your use, it probably isn't worth the effort.

Don't use channel 1119218101 because I just posted it here. :)
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
04-30-2006 09:14
From: Over Sleeper
I have a few objects that all have the same menu. Is there a way to make each one NOT listen to eachother? When I use my menu, they ALL respond!

Bit different approach from the one you used, but since control is menu driven, most likely the user will only interact with one of these items at a time... so in some cases you could probably replace static listen filter with something that's only active for few seconds after the menu is invoked:

CODE

integer listen_handle;

touch_start() {

if( llDetectedKey(0) != llGetOwner() ) return;

listen_handle = llListen( channel, "", id, "" );
llSetTimerEvent( 5 ); // 5 seconds timeout
llDialog( id, caption, buttons, channel );
}

timer() {

llSetTimerEvent( 0 );
llListenRemove( listen_handle );
}

not sure how the performance with installing/removing filters is though, guess in some situations where you expect intensive interaction might be more sensible to go with llListenControl() to enable/disable the filter, instead.
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
04-30-2006 10:12
CODE

integer listen_handle;
default
{
touch_start() {

if( llDetectedKey(0) != llGetOwner() ) return;
listen_handle = llListen( (integer)llFrand(-2147483392.0) - 1, "", id, "" );
llDialog( id, caption, buttons, channel );
llSetTimerEvent( 20.0 ); // 20 seconds timeout
}

timer() {
llSetTimerEvent( 0.0 );
llListenRemove( listen_handle );
}
}
_____________________
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
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
04-30-2006 10:22
Aye, combining it together is considerably more convenient and fail-proof than either on its own <g>

One extra bit perhaps, with the longer timeout could also add llListenRemove() call --and possibly the timer kill too-- to routines invoked by menu, so the filter is killed as soon as it does its work. o.O;
Adriana Caligari
Registered User
Join date: 21 Apr 2005
Posts: 458
04-30-2006 10:24
CODE

integer listen_handle;
default
{
touch_start( integer num )
{

if ( llDetectedKey(0) != llGetOwner() ) return;
key id = llDetectedKey(0); // pick up the detected key
listen_handle = llListen( (integer)llFrand(-2147483392.0) - 1, "", id, "" );
llSetTimerEvent( 20.0 ); // 20 seconds timeout
llDialog( id, caption, buttons, channel );
}

timer() {
llSetTimerEvent( 0.0 );
llListenRemove( listen_handle );
}
}