Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

A couple of questions

MeLight Korvin
Im on da Use
Join date: 4 Jun 2005
Posts: 99
06-23-2005 14:44
Hi,
my first question is related to llListen, in all threads about llListen that i read, guys say not to forget to remove the listen, i was wondering why is it so important and what happens if u dont remove it.

Second question is also about communication, if I have two scripts (on prims), a talking and a listening script, which communicate on, lets say channel 5, how do i make the listening script listen only to the object that belongs to it's owner, an filter all other objects?

thanx
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
06-23-2005 15:13
1) Listens poll sims repeatedly on their designated channel. Leaving a listener on is slightly less laggy than leaving an llSensorRepeat on - it remains active, and checks the sim every so often for the designated chat command(s).

Anyway, you can leave listens "on" if you'd like. A few of them have very little impact on a sim. However, in bulk (100+) and being called frequently, listens can potentially lag sims to death.

Interestingly, it appears that 100 scripts with 1 listener apiece are significantly more laggy than one script with 100.


2) There are several ways to check the "owner" of an object. Since a listener happily supplies the key of the object talking to it, the simplest way is to use a sensor and a detected function.

llDetectedOwner works nicely here.
_____________________
---
Ushuaia Tokugawa
Nobody of Consequence
Join date: 22 Mar 2005
Posts: 268
06-23-2005 16:12
From: Jeffrey Gomez

Since a listener happily supplies the key of the object talking to it, the simplest way is to use a sensor and a detected function.

llDetectedOwner works nicely here.


It seems to me that using llGetOwnerKey inside the listen event would be easier.

CODE

listen(integer channel, string name, key uuid, string message) {
if (llGetOwnerKey(uuid) == llGetOwner()) {
// do something here
}
}
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
06-23-2005 16:14
Ah yes, thanks. I sometimes forget some of these "bridge" commands exist.
_____________________
---
MeLight Korvin
Im on da Use
Join date: 4 Jun 2005
Posts: 99
06-25-2005 00:31
Sorry, this might be a nub question, but what does the (uuid) after the llGetOwnerKey supposed to do/means?
Catherine Omega
Geometry Ninja
Join date: 10 Jan 2003
Posts: 2,053
06-25-2005 00:44
From: MeLight Korvin
Sorry, this might be a nub question, but what does the (uuid) after the llGetOwnerKey supposed to do/means?
(Ushuaia's example...)
CODE
 listen(integer channel, string name, key uuid, string message) {
if (llGetOwnerKey(uuid) == llGetOwner()) {
// do something here
}
}
In brackets following the listen() event, we see a series of variables being declared: an integer named "channel", a string named "name", a key named "uuid" and a string named "message". These four variables are required by the listen event, though you don't have to name them the same way. All that's important is the order and that they be the same types.

So in this context the variable "uuid" will be the key of the speaker that the listen() event has been triggered by. So when the listen() event is triggered, it will determine the key of the owner of the object defined by "uuid" is, and then see if it's the same as the owner of the object that contains this script.

Edit: clarifying.
_____________________
Need scripting help? Visit the LSL Wiki!
Omega Point - Catherine Omega's Blog
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
06-25-2005 02:44
You can also make reference to this.
_____________________
:) Seagel Neville :)
Eggy Lippmann
Wiktator
Join date: 1 May 2003
Posts: 7,939
06-25-2005 03:17
From: Jeffrey Gomez
1) Listens poll sims repeatedly on their designated channel. Leaving a listener on is slightly less laggy than leaving an llSensorRepeat on - it remains active, and checks the sim every so often for the designated chat command(s).

Anyway, you can leave listens "on" if you'd like. A few of them have very little impact on a sim. However, in bulk (100+) and being called frequently, listens can potentially lag sims to death.

Interestingly, it appears that 100 scripts with 1 listener apiece are significantly more laggy than one script with 100.

Do you mean per object? Or do you mean 100 as in any large number?
A script can only have up to 64 listeners, the 65th will crash the script with a "Too Many Listens" runtime error.
Also, listens do not poll sims. The sims poll the listeners ;)
IIRC, every chat message is run through a big queue of listeners, filtered by distance, then by the filtering methods specified in llListen.
MeLight Korvin
Im on da Use
Join date: 4 Jun 2005
Posts: 99
06-25-2005 04:49
Thanx a lot everybody :D, that was very very helpful