Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Make object listen only to avatars?

Adam Ramona
Registered User
Join date: 5 Jan 2005
Posts: 56
01-29-2008 03:08
I evidently have brain diminishing stupiditis. How to make an object listen only to avatars and ignore other objects chatting on the same channel?

Adam
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
01-29-2008 03:10
obtain the key of the speaker and check its size to determine its avatarness.
Adam Ramona
Registered User
Join date: 5 Jan 2005
Posts: 56
01-29-2008 03:26
Ok, so my brain's not so diminished after all: that's what I thought, but it's not very graceful really is it? Would be nicer to have 'integer type' in the parameters of the llListen call, as in llSensorRepeat. Anyway, thanks Squirrel.
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
01-29-2008 08:19
The owner key of an avatar is always (I think) the same as the avatar key. Maybe doing something like this would be easiest...
CODE

listen (integer channel, string name, key id, string message)
{
if (llGetOwnerKey(id) != id)
{
llSay (0, "avatars only! stop talking to me, bozo!");
return;
}
...
_____________________
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
Deanna Trollop
BZ Enterprises
Join date: 30 Jan 2006
Posts: 671
01-29-2008 09:57
From: Meade Paravane
The owner key of an avatar is always (I think) the same as the avatar key.
Testing for a non-zero vector should be faster than comparing two keys.
Nika Talaj
now you see her ...
Join date: 2 Jan 2007
Posts: 5,449
01-29-2008 10:03
From: Deanna Trollop
Testing for a non-zero vector should be faster than comparing two keys.
What, Deanna? Sorry, but can you say more about why this is a unique test for avatar-ness?
_____________________
.
:) To contact forum folks, join the inworld group "The Forum Cartel". New residents with questions about SL more than welcome! We has parties!

:) To contact forum scripters, join the inworld group "Scriptoratti" (thanks Void!). New scripter questions welcome!
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
01-29-2008 10:50
From: Deanna Trollop
Testing for a non-zero vector should be faster than comparing two keys.

Absolutely right but.. uh.. which vector would listen look at and test vs zero?
_____________________
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
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
01-29-2008 11:04
EDIT: Oooops, had it backwards!

CODE
//temp.esl	2008-01-29T19:16:52.505500Z
//Created by: Jesse Barnett
//Copyright: None; Use it as you please!

default {
state_entry() {
llListen(66, "", "", "");
}
listen(integer channel, string name, key id, string message) {
if (llGetAgentSize(id) != ZERO_VECTOR)
llOwnerSay(message);
else {
return;
}
}
}
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Deanna Trollop
BZ Enterprises
Join date: 30 Jan 2006
Posts: 671
01-29-2008 11:16
Even easier, since ZERO_VECTOR evaluates as FALSE:

if( llGetAgentSize( id ) )
{
// id is that of an avatar
}
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
01-29-2008 12:06
Do we know that llGetAgentSize is less expensive than llGetOwnerId plus a key compare?
_____________________
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
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
01-29-2008 17:11
From: Meade Paravane
The owner key of an avatar is always (I think) the same as the avatar key. Maybe doing something like this would be easiest...

Unfortunately, 'llGetOwnerKey(id)' also returns the value of 'id' if called on an object not in the sim. So this may return false positives.

Also, llGetAgentSize() returns ZERO_VECTOR for agents not in the sim. So you may get false negatives.

The most sure way to test whether a speaker is an avatar or not is probably to do a 'llRequestAgentData(id, DATA_NAME)', but unfortunately that requires waiting for another event and implementing some kind of timeout. It might be that llGetObjectDetails() might help here too, but I'm not sure.
Deanna Trollop
BZ Enterprises
Join date: 30 Jan 2006
Posts: 671
01-29-2008 21:51
From: Hewee Zetkin
but unfortunately that requires waiting for another event and implementing some kind of timeout.
And if the dataserver is running slower than expected, that too would essentially return a false negative.

From: someone
It might be that llGetObjectDetails() might help here too, but I'm not sure.
Hmmm... could try llGetObjectDetails( id, (list)OBJECT_CREATOR ), which would return a list containing NULL_KEY if id were an agent, or just a null list if id is outside the sim, so at least this method should distinguish between the two, even if outside-of-sim agents and objects are still indistinguishable from each other.

BTW, sorry for the confusion above, all. I was over-succinctly comparing Squirrel and Meade's methods.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
01-30-2008 15:34
just to be odd, I have no idea if it'd work, or if it suffers the same false negatives for out of sim avs (likely), but it's an idea...

if (llGetAnimation( id ) != "";)

another to try would be object details and object creator (null for av's)

and I'm not sure what llGetObjectPrimCount would returns on an av, could be 0 could be every attachment....
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Day Oh
Registered User
Join date: 3 Feb 2007
Posts: 1,257
01-30-2008 16:45
This is really interesting. I usually just assume alot, like that since the agent just triggered a listen event, I expect the sim to be able to do llGetOwnerKey...

And it kinda seems like if it couldn't do that, I wouldn't expect it to be able to do llGetAgentSize either...
_____________________
Deanna Trollop
BZ Enterprises
Join date: 30 Jan 2006
Posts: 671
01-30-2008 22:33
From: Void Singer
if (llGetAnimation( id ) != "";)
Yup, returns a blank string for Avs outside the sim, so it'd give false negatives.

From: someone
another to try would be object details and object creator (null for av's)
Is there an echo in here? :p

From: someone
and I'm not sure what llGetObjectPrimCount would returns on an av, could be 0 could be every attachment....
Returns 0 for Avs... but curiously, also returns 0 if passed the key of an attachment in the same sim. And, of course, also returns 0 for objects outside the sim, so that's 2 possible types of false positive.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
01-31-2008 02:13
From: Day Oh
This is really interesting. I usually just assume alot, like that since the agent just triggered a listen event, I expect the sim to be able to do llGetOwnerKey...

And it kinda seems like if it couldn't do that, I wouldn't expect it to be able to do llGetAgentSize either...

depends, what's the behavior today for avatars and objects talking accross sim boundries? (I say today because I'll be damned if I remember what it is now, only that I remember it having changed in the last 4 years at least once)
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
01-31-2008 07:58
/me had a new JIRA suggestion for llDetectedType all ready to submit so that people could easily do what the OP wanted. Then, for some reason, I checked the wiki and found that it's already there.

I know the OP was looking to filter for avatar types and not have the listen event triggered at all for objects but, lacking the ability to do that, isn't this exactly the thing to use?

http://wiki.secondlife.com/wiki/LlDetectedType
_____________________
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
Deanna Trollop
BZ Enterprises
Join date: 30 Jan 2006
Posts: 671
01-31-2008 11:01
No, because the llDetected* functions only work inside sensor, touch* and collision* event handlers, not listen. What would be needed is a function to which one can pass a key (i.e. the id parameter of the listen event handler) and have it return the type of the associated object/avatar.
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
01-31-2008 12:24
Oh yeah.. There's that whole "it doesn't work" bit. That would be a problem, wouldn't it?

Never mind. Ignore me.
_____________________
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
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
01-31-2008 15:08
s'ok meade, I had the same thought before realizing there's no detected* in listens, I even considered firing a sensor, but that seems like a lot of work for a simple problem.
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Winter Ventura
Eclectic Randomness
Join date: 18 Jul 2006
Posts: 2,579
01-31-2008 18:54
really, the simplest solution is just:

CODE
if (llGetOwnerKey(id) != id) return; // bail out, speaker is not a person.


This screens out all objects.
The owner of an agent, is the agent. The owner of an Object, must be an agent.
If speaking id is the same as the owner of the speaking id, then yes, it's an agent.

conversely, if you want to screen out all chat that is not from the owner's objects (like huds)

CODE
if (llGetOwnerKey(id) != llGetOwner()) return; // bail out, speaker is not my owner or owned by my owner.


This filter has the upshot of also allowing llDialogs and manually typed commands from the owner. (whereas, the llListen(0, "", llGetOwner(), "";); type of filter will NOT hear huds!)
_____________________

● Inworld Store: http://slurl.eclectic-randomness.com
● Website: http://www.eclectic-randomness.com
● Twitter: @WinterVentura
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
01-31-2008 20:11
From: Winter Ventura
really, the simplest solution is just:

CODE
if (llGetOwnerKey(id) != id) return; // bail out, speaker is not a person.


This screens out all objects.
Except it was established:
From: Hewee Zetkin
Unfortunately, 'llGetOwnerKey(id)' also returns the value of 'id' if called on an object not in the sim.
Adding a bit to the "echo" :p if llGetObjectDetails() ends up working the way I think is intended after the fix for SVC-774, it should accurately discriminate between objects and agents up to 96m away in another sim. But that still leaves a 4m thick arc in that neighboring sim from which a shouting agent and an llShout()ing object couldn't be distinguished.