Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

how to use Sensor to scan for partial name of agent

Gattz Gilman
Banned from RealLife :/
Join date: 29 Feb 2004
Posts: 316
10-13-2005 16:18
Im scatching my head of this one. only thought on how is have llSensorRepeat, and continually scan for agents and add names to a list, then going through the list and use llGetSupString to compare the partial name to the full name.

But i guess the one question i got, when the llSensorRepeat is running, does it just pickup one agent every cycle or does it detect all agents in range at that time? And on one call of the llSensorRepeat, will it scan the same agent or just scan it once?

thank you :)
_____________________
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
10-13-2005 16:43
From: Gattz Gilman
Im scatching my head of this one. only thought on how is have llSensorRepeat, and continually scan for agents and add names to a list, then going through the list and use llGetSupString to compare the partial name to the full name.

But i guess the one question i got, when the llSensorRepeat is running, does it just pickup one agent every cycle or does it detect all agents in range at that time? And on one call of the llSensorRepeat, will it scan the same agent or just scan it once?

thank you :)
It will return a maximum of 16 agents within the range of the sensor. Each cycle of a repeat sensor is really just the same exact scan, automatically done, so it will report the same agents if they've not left or been added to in the range of the sensor.
_____________________
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
10-13-2005 16:51
AFAIK, it'll return the first 16 it finds every time. It's not one at a time, that's what the num_detected parameter is for, so you know how many it found. So the only difference between llSensor and llSensorRepeat is that repeat scans repeatedly. It won't return any additional agents that llSensor didn't find. (Except for the obvious, of course, where you set up a 5 minute timer for the repeat, and 5 minutes later someone is within range who wasn't in range before).

And yes, if you have a partial name, I think you'll have to scan for everyone and check the name against the ones returned. But you don't need to add them to a list just to search through them, you could loop on the names, since you know how many names were returned - num_detected.

So:

CODE

sensor(integer num_detected)
{
integer i;

for (i = 0; i < num_detected; i++)
{
if (llSubStringIndex(llDetectedName(i), partialName) != -1)
{
// You found someone whose name matches the partial string you have
}
}
}


You'll have to watch out for uppercase/lowercase mismatches.