Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Confused about Listen Functions

Lief Rush
Registered User
Join date: 15 Dec 2006
Posts: 18
01-01-2008 10:22
Greetings and Happy New Year!!

I am trying to understand how llListen works..

I understood that I could set a script to listen to a certain channel, and react to that channel... But I seem to not be doing something right, as my scripts seem to be listening to all the channels, not just the one I am hoping for...

This is the script that is waiting for commands:

_____________________________CODE BELOW___________
integer button3 = -7726153;


default
{
state_entry()
{
llListen(button3,"", "","";);
}

listen(integer button3, string name, key id, string mes)
{
llSetTexture(mes, ALL_SIDES);

}




}

_______________________________________________

I want to have several prims with the listen script in them all with different channels... Then I have a script that sends out texture keys on the different channels.. Simple I thought, but all the prims change to the latest texture sent, not just the one listening on the channel the message is sent on? Any body see what noob mistake I am making?

Thanks!!
Xhawkx Holden
Registered User
Join date: 1 Nov 2006
Posts: 86
01-01-2008 11:05
Use this:

integer button3 = -7726153;

default
{
state_entry()
{
llListen(button3,"",NULL_KEY,"";);
}

listen(integer ch, string name, key id, string mes)
{
llSetTexture(mes, ALL_SIDES);

}

}
Lief Rush
Registered User
Join date: 15 Dec 2006
Posts: 18
Hi Hawk.. Tried that.. still no luck...
01-01-2008 12:29
I have made 5 blocks with the same script as above, except i use a different channel for each script/listen... I expected that i could send something like this:


llSay(channel1,"whatevertexturekey";);
llSay(channel2,"whatevertexturekey";);
llSay(channel3,"whatevertexturekey";);
llSay(channel4,"whatevertexturekey";);
llSay(channel5,"whatevertexturekey";);


But instead all the boxes with the script/listeners change, cycling thru all 5 textures on each box.. So clearly, they are all hearing the message sent on the other channels with the texture keys... I hope I made that clear...

The changes you recommended did not effect the problem... Thanks for the response, and I suspect I am doing something stupid, that makes this act like this...

Thanks!!
Deanna Trollop
BZ Enterprises
Join date: 30 Jan 2006
Posts: 671
01-01-2008 12:33
From: Lief Rush
my scripts seem to be listening to all the channels, not just the one I am hoping for...
That isn't possible. The listen event handler will only be raised when a message fitting the filters previously established by llListen is heard.


From: someone
listen(integer button3, string name, key id, string mes)
One thing about this line... by naming the first parameter button3, you're not setting it equal to the global integer button3 specified above, you're just declaring a local integer named button3, which is then initialized with the value of the channel the message was heard on. The name of this parameter is unimportant, as are the names of any event handler parameters, except for reference within the event handler itself.


From: someone
Any body see what noob mistake I am making?
Without seeing examples of how the scripts in the individual prims differ from each other, it's difficult to tell. As to the one script posted, it certainly appears that it should only change textures when a message is received on channel -7726153.
Kidd Krasner
Registered User
Join date: 1 Jan 2007
Posts: 1,938
01-01-2008 12:46
I wouldn't be surprised if the bug is in the script that's sending the message as opposed to the listener, which seems right.

So here's a suggestion: For testing purposes, don't use the big negative number. Instead, just use 1, 2, 3, 4, .... for the prims. Then you can test the listener by typing things like /1 TextureForPrim1 in chat, and get the listener side working without involving the sending object.
Lief Rush
Registered User
Join date: 15 Dec 2006
Posts: 18
01-01-2008 13:06
Hi Kidd... I took your advice and simplified the channel.. it works fine.. now rebuilding it while it works and hopefully i don't break it again when i add the negative channel back in... No clue why it wouldn't work right earlier.. THANKS!!