Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llSensor question

Surina Skallagrimson
Queen of Amazon Nations
Join date: 19 Jun 2003
Posts: 941
05-20-2005 04:26
I understand that llSensor() can detect all objects by leaving the name field as null, or a single object by specifying a name. However, can I detect multiple names in one llSensor?

Something along the lines of llSensor("object A" | "Object B" | "Object C", etc....);

or even use wildcard chars.. llSensor("object *",.......); or llSensor("object??",....);

My aplication only needs to detect 2 or 3 object names, but I'd prefer to only use one llSensor.

Thanks in advance....
_____________________
--------------------------------------------------------
Surina Skallagrimson
Queen of Amazon Nation
Rizal Sports Mentor

--------------------------------------------------------
Philip Linden: "we are not in the game business."
Adam Savage: "I reject your reality and substitue my own."
Luke Ramona
Registered User
Join date: 3 Apr 2005
Posts: 32
05-20-2005 05:15
From: Surina Skallagrimson
I understand that llSensor() can detect all objects by leaving the name field as null, or a single object by specifying a name. However, can I detect multiple names in one llSensor?

Something along the lines of llSensor("object A" | "Object B" | "Object C", etc....);

or even use wildcard chars.. llSensor("object *",.......); or llSensor("object??",....);

My aplication only needs to detect 2 or 3 object names, but I'd prefer to only use one llSensor.

Thanks in advance....


Well I doubt you could use wildcards as no other function seems to support wildcard pattern matching, however the example on the llSensor() Wiki says that you can use bitwise operators to set multiple conditions for the llSensor() function:

CODE

llSensor("", NULL_KEY, AGENT | ACTIVE, 25, PI);


So.. Your first solution to the problem should work, for example:

CODE

llSensor("object1" | "object2" | "object3", NULL_KEY, ACTIVE, 25, PI);


An alternative to this would be to check what has been detected in the Sensor() event, for example:

CODE

default
{

state_entry()
{
// Detect the 16 closest ACTIVE objects within 10m range
llSensor("", NULL_KEY, ACTIVE, 10, PI);
}

sensor(integer total_number)
{
integer i;
for ( i = 0; i < total_number; i++ )
{
if (llDetectedName(i) == "object1")
{
// Perform operations on "object1"
}
}
}
}
Chage McCoy
Aerodrome Janitor
Join date: 23 Apr 2004
Posts: 336
05-20-2005 05:25
What luke said.

Sensors will not handle multiple name filtering in the event itself, so you must use LSL to manually filter.
Ace Cassidy
Resident Bohemian
Join date: 5 Apr 2004
Posts: 1,228
05-20-2005 05:29
Using llSensor("object1" | "object2" | "object3"...) WILL NOT WORK the way you want.

Your best best is to make multiple calls to llSensor().

- Ace
_____________________
"Free your mind, and your ass will follow" - George Clinton
Laukosargas Svarog
Angel ?
Join date: 18 Aug 2004
Posts: 1,304
05-20-2005 06:09
Ace is correct. I have a hunch I know what you're playing with ;)

I use separate states for each sensor, this way the script can easilly respond to what's found/not found and it saves using loads of messy if() statements.

state_entry()
{
llSensor ( ... );
}

sensor ( ... )
{
do found

change to next state

}

no_sensor ()
{
change to next state
}
Laukosargas Svarog
Angel ?
Join date: 18 Aug 2004
Posts: 1,304
05-20-2005 06:23
*** EDIT ***

removed nonsense.

*** EDIT ***

I often forget, as I did in the nonsense I removed above, that llSensor will only return the first 16 objects it finds. So if you use a blank name field to search when there are many objects within range, the chances are you will not find what you are looking for.
Laukosargas Svarog
Angel ?
Join date: 18 Aug 2004
Posts: 1,304
05-20-2005 06:28
From: someone
however the example on the llSensor() Wiki says that you can use bitwise operators to set multiple conditions for the llSensor() function:


AFAIK this is only true for the "type" field.
Surina Skallagrimson
Queen of Amazon Nations
Join date: 19 Jun 2003
Posts: 941
05-20-2005 07:05
From: Laukosargas Svarog

I often forget, as I did in the nonsense I removed above, that llSensor will only return the first 16 objects it finds. So if you use a blank name field to search when there are many objects within range, the chances are you will not find what you are looking for.


This is the problem I have, I need to sense two or three specific object names and a blank name field would swamp the sensor result set.


Also, can anyone tell me if llSensor works across sim boundrys yet?
_____________________
--------------------------------------------------------
Surina Skallagrimson
Queen of Amazon Nation
Rizal Sports Mentor

--------------------------------------------------------
Philip Linden: "we are not in the game business."
Adam Savage: "I reject your reality and substitue my own."