Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

How To Stop Extra Listens???

Mako Davidson
Registered User
Join date: 27 Jun 2006
Posts: 56
06-26-2007 08:51
Hello peolpe once again. I am creating a HUD that whispers instructions on a negative channel to another object I'm wearing when it's buttons are touched. I'm wondering if there is a way of preventing the object that I'm wearing from listening to someone else using the same HUD and channel number for its whispers. Thank you.
RJ Source
Green Sky Labs
Join date: 10 Jan 2007
Posts: 272
06-26-2007 08:53
The listen event handler allows you to specify the key of the talker to listen to (rather than just NULL_KEY), which will filter out other talkers on that same channel.
Mako Davidson
Registered User
Join date: 27 Jun 2006
Posts: 56
thanks RJ
06-26-2007 10:02
I don't suppose you have a couple of example lines I could work into my script please. I haven't specified a key to listen to before and so am unsure of what to put???
Daten Thielt
Registered User
Join date: 1 Dec 2006
Posts: 104
06-26-2007 10:19
default
{
state_entry()
{
llListen(0, "","","";); // This is listen 0
}

touch_start(integer j)
{
llListen(4, "","","";); // This is listen 1
}

colisioin_start(integer o)
{
llListenRemove(0); // Remove listen 0
llListenRemove(1); // Remove Listen 0
}
}

Another example

default
{
state_entry()
{
integer listen = llListen(4, "","","";); //Listen
}
touch_start(integer j)
{
llSay(0, (string)listen); //This will tell you the number of the integer listen.
}

}

In other words the listens will go up in number the further down they go, so if u have a listen in the default state entry it will always be 0, any listen under that and u just ++
Shadow Subagja
Registered User
Join date: 29 Apr 2007
Posts: 354
06-26-2007 10:34
The function type for llListen is:
integer llListen(integer channel, string name, key id, string msg)

This allows you to specify not only channel, but an avatar name or key. So if you want to listen on channel 0 for messages, but only to the wearer of the HUD:

llListen(0, "", llGetOwner(), "";);

Which roughly translates into:
listen on channel 0, for any name, with my owner's key, saying any message.

Then nobody else can say anything to that object on that channel except the wearer.
Mako Davidson
Registered User
Join date: 27 Jun 2006
Posts: 56
woooot
06-26-2007 11:06
It worked using llGetOwner(), thankyou ever so much.
Mako Davidson
Registered User
Join date: 27 Jun 2006
Posts: 56
Oh no I spoke to soon...
06-26-2007 11:24
Hmmm it seems this won't work either, I need the HUD I'm wearing to be able to say something to another separate object I'll be wearing. Therefore it will be the HUD object speaking not the owner. Any other suggestions please???
Milambus Oh
Registered User
Join date: 6 Apr 2007
Posts: 224
06-26-2007 11:30
You need to tell the object the key for your HUD somehow.

This can be done a few different ways:
1. Have the HUD broadcast its key, and receive a confirmation message from the object when it is attached.

2. Have the object rez the HUD, or vise versa and the information during item creation.

3. Manually enter the UUID in some way, hard coded, notecard or description field.
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
06-26-2007 11:33
From: Mako Davidson
Hmmm it seems this won't work either, I need the HUD I'm wearing to be able to say something to another separate object I'll be wearing. Therefore it will be the HUD object speaking not the owner. Any other suggestions please???

I'm surprised that didn't work..

Any state changes in these scripts? A state change will close any open listens you have going...
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!!
- Go here: http://jira.secondlife.com/browse/SVC-1224
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
Pip Helios
Registered User
Join date: 29 Sep 2006
Posts: 22
06-26-2007 11:41
If I understand what you're looking for this is what you need.

listen( integer channel, string name, key id, string message )
{
if ( llGetOwnerKey(id) == llGetOwner() )
{
llWhisper( 0, "I hear and obey, master." );
}
else
{
llWhisper( 0, "You're not the boss of me." );
}
}
Pip Helios
Registered User
Join date: 29 Sep 2006
Posts: 22
06-26-2007 11:46
From: Meade Paravane
I'm surprised that didn't work..

Any state changes in these scripts? A state change will close any open listens you have going...

Objects have their own keys, not the owners. In his case he needs to verify the owner of the object talking. If it's using llGetOwner() it only hears the owner and ignores all else... including objects. By doing if(llGetOwnerKey(id)==llGetOwner()) we check the key of the owner, interesting note is that avatars own themselves (their kind of like objects) so that if returns true if you talk to it. Now if you JUST wanted a HUD and wanted it to ignore when the avatar talks you would want to do something like if(llGetOwnerKey(id)==llGetOwner() && id != llGetOwner()). Their you listen for objects owned by you but checking that the key we hear isn't the owner.
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
06-26-2007 11:59
Oh.. Right.. Sorry.. Is it Friday yet?
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!!
- Go here: http://jira.secondlife.com/browse/SVC-1224
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
Mako Davidson
Registered User
Join date: 27 Jun 2006
Posts: 56
thankyou people
06-26-2007 12:02
I'll give it a go using the if statement...
Pip Helios
Registered User
Join date: 29 Sep 2006
Posts: 22
06-26-2007 12:20
From: Meade Paravane
Oh.. Right.. Sorry.. Is it Friday yet?


I wish! :) I could use a nice all day nap. Yeah almost all I work on now is interprim communication and HUDs, still catch surprises, like I forgot that lldialog actually makes the avatar speak and works with llGetOwner(), that was a nice surprise that's delagged a large project of mine some. Anyhew lemme know if that worked, if it didn't I need to do a lot of recoding XD. One point you might want to keep in mind though it doesn't really apply hear. llGetOwnerKey() does not work if owners aren't in sim, if you ever need to verify the owner of a object and their out of sim use a data server request (that's a whole new type of pain in your butt)
Mako Davidson
Registered User
Join date: 27 Jun 2006
Posts: 56
thanks Pip worked like a charm :)
06-26-2007 12:45
and thanks to everyone else who had some input.