Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Sensor problems...

Bret Hornet
Registered User
Join date: 6 Jun 2005
Posts: 29
06-13-2005 18:57
I wrote this script to target a particular object to send a paritcle stream to. Unfortunately it doesn't find the object by the name I want. I'm looking for an object named "Stream Target" and it always falls into the no_sensor() event. I've tried setting the name to "" and it finds other objects sitting around me. I've also tried specifying other names...those work too.

Not quite sure what the problem is. Stream Target is just a basic sphere I rezed, nothing special about it... I also checked the spelling and even went so far as to copy and paste the name, but for some reason it can't find.

Anyone know what's going on?

CODE

key target_key;

default
{
state_entry()
{
llSay(0, "Test Article Online.");
llSay(0, "Mode: Safe");
llSay(0, "Beacon: Off");
llSay(0, "Stream: Off");

llListen(0,"",llGetOwner(),"");
}

listen(integer channel, string name, key id, string message)
{
if(id==llGetOwner())
{
if (message=="Greetings")
{
llSay(0,"Recognize authorized personnel.");
}

if (message=="stream on")
{
llSensor("Stream Target", NULL_KEY, AGENT|ACTIVE|PASSIVE|SCRIPTED, 80.0, PI);
}

if (message=="stream off")
{
llSay(0,"Stream Deactivated.");
llParticleSystem([]);
}

if (message=="beacon on")
{
llSay(0,"Unimplemented.");
}

if (message=="beacon off")
{
llSay(0,"Unimplemented.");
}

}
}

sensor(integer num_detected)
{
integer i;
for (i = 0; i < num_detected; i++)
{
llSay(0, llDetectedName(i));
}
}

no_sensor()
{
llSay(0, "Unable to find stream target.");
}

}
Ushuaia Tokugawa
Nobody of Consequence
Join date: 22 Mar 2005
Posts: 268
06-13-2005 19:01
If it's just a basic sphere you should only have to use PASSIVE as your type parameter.
Bret Hornet
Registered User
Join date: 6 Jun 2005
Posts: 29
yeah
06-13-2005 19:10
That's what I thought, but I figured I'd throw all types at it in case I was picking the wrong one.

If I hard code in the sphere's key, the particle stream will engage and target the sphere...

Any other reasons the sensor might not be picking it up?
Bret Hornet
Registered User
Join date: 6 Jun 2005
Posts: 29
06-13-2005 19:16
edit: The problem is I typed == instead of = when trying to assign the key... dah! Anyone want to take a stab at why the it still can't target an unscripted object?

Ok, adding the script to the sphere to get the key seems to have made it detectable to the sensor. I guess it's picking it up as "SCRIPTED" ...not sure why it doesn't pick it up with out the script on it.

But now there's a second problem. If I code sensor this way it will target the particle stream correctly, unfortunatly i just hard coded the key (replaced with ?'s):

CODE


sensor(integer num_detected)
{

llSay(0,"Stream Activated.");

/target_key = "????????-????-????-????-????????????";

llParticleSystem([
PSYS_PART_FLAGS, PSYS_PART_EMISSIVE_MASK |
PSYS_PART_TARGET_POS_MASK,
PSYS_SRC_TARGET_KEY, target_key,
PSYS_SRC_PATTERN, PSYS_SRC_PATTERN_ANGLE_CONE,
PSYS_SRC_ANGLE_BEGIN, 0 + 0.25,
PSYS_SRC_ANGLE_END, 0 - 0.25,
PSYS_PART_START_COLOR, <0.3, 0.3, 1.0>,
PSYS_SRC_BURST_RATE, .025,
PSYS_SRC_BURST_PART_COUNT, 1,
PSYS_PART_START_SCALE, <0.1, 0.1, 0.0>,
PSYS_PART_END_SCALE, <0.1, 0.1, 0.0>]);
}



But if I use this, it targets the prim that's generating the particles which means it's not finding the key it's looking for... Though the key it prints out in llSay matches the objects key. I'm thorougly perplexed :(

CODE

sensor(integer num_detected)
{

llSay(0,"Stream Activated.");

llSay(0, llDetectedKey(0));
target_key == llDetectedKey(0);

llParticleSystem([
PSYS_PART_FLAGS, PSYS_PART_EMISSIVE_MASK |
PSYS_PART_TARGET_POS_MASK,
PSYS_SRC_TARGET_KEY, target_key,
PSYS_SRC_PATTERN, PSYS_SRC_PATTERN_ANGLE_CONE,
PSYS_SRC_ANGLE_BEGIN, 0 + 0.25,
PSYS_SRC_ANGLE_END, 0 - 0.25,
PSYS_PART_START_COLOR, <0.3, 0.3, 1.0>,
PSYS_SRC_BURST_RATE, .025,
PSYS_SRC_BURST_PART_COUNT, 1,
PSYS_PART_START_SCALE, <0.1, 0.1, 0.0>,
PSYS_PART_END_SCALE, <0.1, 0.1, 0.0>]);
}
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
06-13-2005 20:46
Hello Bret,

I'm little familiar with sensor and for loop, so I want to ask you.
From: Bret Hornet

CODE

sensor(integer num_detected)
{
integer i;
for (i = 0; i < num_detected; i++)
{
llSay(0, llDetectedName(i));
}
}

In your script, how much is this num_detected? Is your "Stream Target" more than two?
If it is just one, num_detected is one? hmm... I wonder if it is possible to count 0 < 1 as an integer. Sorry, if I pointed wrong.
_____________________
:) Seagel Neville :)
Bret Hornet
Registered User
Join date: 6 Jun 2005
Posts: 29
06-13-2005 20:56
I thought about the index issue. The real script actually just uses [0].

If the sphere named "Stream Target" has a script on it, everything works. If it's just a basic prim the target lookup fails, and the particle stream ends up targeting the source prim.

I made sure PASSIVE is listed as one of the types (infact i used all types just to be sure i wasn't going crazy) and it just flat refuses to target a basic prim for whatever reason.

The work around I have is to just put a dummy script on the target, but it seems odd that it doesn't work as advertised. :(
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
06-14-2005 02:03
If you read the wiki carefully scripted doesn't OR together quite as you seem to think it should. Adding '| SCRIPTED' to your sensor chain will only detect objects containing scripts, be they active or passive - things that if you put your mouse over them the hover tips contains the word Script in the bottom line.

So your sensor script is working exactly as it should just not as you (nor I at first) expected. Putting any only script in your sphere will make it active or passive and scripted, removing scripted will detect it without a script. In fact if you know it's always going to be a neutral, unscripted target object using just PASSIVE might be worth it.

I've never seen an indication of how the sensor system works for time. Anyone out there know, is a llSensor("", "", PASSIVE, 96, PI) faster than say llSensor("", "", ACTIVE | PASSIVE, 96, PI) ?