Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Capturing partial messages.

Lucius Obviate
Evil Incarnate
Join date: 5 Dec 2006
Posts: 15
02-13-2007 03:16
Is it possible to use llListen to capture part of chat being transmitted by an object?

Example:

Object Spider says: Welcome to my parlor little fly.

Would it be possible to capture "parlor little fly" using llListen?
Woopsy Dazy
Registered User
Join date: 12 Nov 2006
Posts: 173
02-13-2007 03:54
Seems like the answer is no...

Q: Can a wildcard be used for the msg argument? I only want to monitor text that begins with "ls" but can be anything after it ("on", "off", "silence", etc).
A: Wildcards are not supported. You'll want to use llGetSubString or llSubStringIndex in your listen() event.

So must do something like this:

CODE

if (llSubStringIndex(sentence, "parlor little fly") == TRUE)
{
llOwnerSay("Spider said IT!");
}
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
Yes
02-13-2007 05:20
You can either listen to a particular object by specifying its key or its name when you set up the listen.

integer llListen(integer channel, string name, key id, string msg)

i.e.

CODE

default
{
state_entry()
{
llListen(0, "Spider", NULL_KEY, "");
}

listen(integer channel, string name, key id, string message)
{
llSay(0,"Spider just said " + message);
}
}
Tyken Hightower
Automagical
Join date: 15 Feb 2006
Posts: 472
02-13-2007 05:24
From: Woopsy Dazy
Seems like the answer is no...

Q: Can a wildcard be used for the msg argument? I only want to monitor text that begins with "ls" but can be anything after it ("on", "off", "silence", etc).
A: Wildcards are not supported. You'll want to use llGetSubString or llSubStringIndex in your listen() event.

So must do something like this:

CODE

if (llSubStringIndex(sentence, "parlor little fly") == TRUE)
{
llOwnerSay("Spider said IT!");
}

I'm pretty sure this will return FALSE if the substring is at the beginning of the message, where its index should be 0.
_____________________
Woopsy Dazy
Registered User
Join date: 12 Nov 2006
Posts: 173
02-13-2007 06:02
Question was to to listen to part of text. The llListen DO support textstrings but not wildcards like "*parlor little fly*". To illustrate it:

llListen(0, "Spider", NULL_KEY, "parlor little fly");

Object say's: "parlor little fly" - llListen event triggered
Object say's: "Welcome to my parlor little fly." - llListen event NOT triggered

So you have to listen to everything the object say's, then do another action (ex llSubStringIndex) to verify if part of the text contains "parlor little fly".

I could be wrong but that's how I understood the wiki. I can't verify any code atm, so sorry if my previous sample wasn't 100% correct.
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
My Apologies
02-13-2007 06:11
From: Woopsy Dazy
Question was to to listen to part of text. The llListen DO support textstrings but not wildcards like "*parlor little fly*". To illustrate it:

llListen(0, "Spider", NULL_KEY, "parlor little fly");

Object say's: "parlor little fly" - llListen event triggered
Object say's: "Welcome to my parlor little fly." - llListen event NOT triggered

So you have to listen to everything the object say's, then do another action (ex llSubStringIndex) to verify if part of the text contains "parlor little fly".

I could be wrong but that's how I understood the wiki. I can't verify any code atm, so sorry if my previous sample wasn't 100% correct.


Ahh sorry my apologies, I misread the post.
As Tyken pointed out, your use of llSubStringIndex is close but not 100% as it wil return
-1 if its NOT found

CODE

integer index = llSubStringIndex(sentence, "parlor little fly");
if(index >= 0)
{
llOwnerSay("Spider said IT!");
}
Lucius Obviate
Evil Incarnate
Join date: 5 Dec 2006
Posts: 15
02-13-2007 10:18
Thanks for the help that was exactly what I was looking for. :)

***edit***

This is what I wound up using to get it to work properly.

CODE

integer index = llSubStringIndex(sentence, "parlor little fly");
if(index != -1)
{
llOwnerSay("Spider said IT!");
}