Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Help with llSensor

IBME Swindlehurst
Registered User
Join date: 5 Mar 2007
Posts: 139
12-19-2007 19:08
I'm having problems combining the "Object Type Constants" in llSensor. If I use them individually they seem to work, but any combination of different "Types" doesn't work. The script compiles and saves just fine but doesn't work as expected. Is this a bug, OR more likely me doing something wrong? Please help me, THANKS in advance.

Here is my simple llSensor script.

default
{
state_entry()
{
}

touch_start(integer total_number)
{
llSensor("", NULL_KEY, AGENT|ACTIVE|PASSIVE|SCRIPTED, 5.0, 2 * PI);
}
sensor (integer numberDetected)
{
integer i;
for (i = 0; i < numberDetected; i++)
{
llOwnerSay( "Detected " + llDetectedName(i));
}
}

no_sensor()
{
llOwnerSay("Nothing is near me at present.";);
}

}
Tecak Oyen
Registered User
Join date: 13 Jun 2007
Posts: 18
12-19-2007 21:23
I tried the script and it seemed to work for me. It detected an object 5 meters from the cube. What behavior did you expect?

[edit... spoke too soon]

Ok.. I see what you're seeing now... No agents being detected when all flags are present.

If I remove the "SCRIPTED" flag, I think I get the behavior you desire.

BTW, the arc should be PI not 2*PI for a full sphere.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
12-19-2007 21:59
nothing wrong with the code that I see, but you should note sensors won't detect themselves or anything they are a part of (for instance YOU if they are attached, exception, if they are in a child prim).

also the scripted flag tends to act strangely combined with other flags.... in your usage, it probably won't detect av's or non-sripted objects, see this link for details

a few small notes though... you only need to specify PI for the arc, since the arc is measured as a cone of center (+X axis) to side.... meaning that it effectively doubles (compared to an arc from cone side to cone side).... also you can replace NULL_KEY with "" for the same effect and use less memory and code.... also specifying 16 instead of AGENT|ACTIVE|PASSIVE|SCRIPTED will have the same effect, less memory, less code, but also less readable
_____________________
|
| . "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...
| -
IBME Swindlehurst
Registered User
Join date: 5 Mar 2007
Posts: 139
12-20-2007 04:58
Removing "SCRIPTED" makes it work as I expected. After reading the info in the link you provided, the statement "Combining the SCRIPTED flag with others can lead to somewhat unintuitive results:" describes in a nutshell the results I was seeing. It seems like a glitch/bug to me, but removing "SCRIPTED" is a GREAT workaround for my purposes.

THANK YOU for your very timely and professional help. It would have taken weeks waiting for a "Support Ticket".