Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Sensor Questions

Nyx Alsop
Registered User
Join date: 14 Dec 2008
Posts: 252
11-13-2009 12:46
What's the fastest Senor Repeat can work at?

How do I detected Multiple object names I tried || but didn't work
Viktoria Dovgal
Join date: 29 Jul 2007
Posts: 3,593
11-13-2009 13:36
It's nominally 0.05 seconds, but don't expect to get anywhere near that consistently. The actual repeats you'll get are very sensitive to sim load. On the other side of the coin, sensors have a tendency to eat up a lot of a sim's script time, not just because they scan for stuff but also because they inevitably involve fairly expensive list slicing and dicing. The game is to make your sensors repeat as far apart as you can, and use as small a range as you can get away with, and still do the job.

For the name thing, you are out of luck, you would need one sensor per name. It's the same situation as listen filters, we don't have anything fancy like wildcards or regex to use there.
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
11-13-2009 13:41
From: Viktoria Dovgal
...sensors have a tendency to eat up a lot of a sim's script time...

Yes.. Any time you find yourself asking how quickly you can repeat a sensor, it's a good time to take a step back. Not that it's something you should never do - just that it's sortofa red flag.

From: Viktoria Dovgal
...you would need one sensor per name.

Does that work? I thought (but have never tried) that sensors were like timers - when you do one, it nukes any other ones you've done..
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!!
- Go here: http://jira.secondlife.com/browse/SVC-1224
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
11-13-2009 13:42
You'll have to experiment to see how small the rate parameter can be. The faster a sensor has to work, though, the more likely it is to be affected by lag. Worse still, a fast sensor is going to create a whole mess of lag. So... don't do it unless you want to create a lot of problems and lose a few friends.

You can't look for multiple object in a single sensor sweep. If you want to look for several objects, you'll need to do seperate sweeps for them. If you're tempted to do something like this ...

CODE

sensor (integer num_detected)
{
integer i;
for (i=0;i<=num_detected;++i)
{
if (llDetectedName(i) == "Item 1" || llDetectedName(i) == "Item 2" || llDetectedName(0) == "Item 3")
{
//Do stuff
}
}
}


then you'll really slow things down, so don't do that either.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
Viktoria Dovgal
Join date: 29 Jul 2007
Posts: 3,593
11-13-2009 13:44
From: Meade Paravane
Does that work? I thought (but have never tried) that sensors were like timers - when you do one, it nukes any other ones you've done..

Yep, they clobber, but only in the same script. You can do more than one sensor script in the same object.
Kayaker Magic
low carbonated footprint
Join date: 11 Sep 2008
Posts: 109
11-13-2009 13:54
In llSetTimerEvent there is a brief mention of a “Default event delay - Only so many events can be triggered per second” but no details on how many that is. In the LSL Wiki it is suggested that you can't get more than about 25 events per second, so a rate of less than 0.04 has no real effect. However, since many LSL Library calls have a 0.2 second delay built in, I've rarely been able to get more than 5 events per second, so a rate of 0.2 is the smallest I normally use.

To detect multiple object names you have to leave the name field "" which detects all objects. If you have a shorter list than that, you must check for them yourself. For example:

llSensorRepeat( “”, “”, PASSIVE, 50, PI,0.2);
. . .
sensor(integer num)
{
while(--num>=0)
{
if (llDetectedName(num)==”wall”)
llOwnerSay(“found a wall”);
if (llDetectedName(num)==”floor”)
llOwnerSay(“found a floor”);
}
}
Viktoria Dovgal
Join date: 29 Jul 2007
Posts: 3,593
11-13-2009 13:57
From: Kayaker Magic
In llSetTimerEvent there is a brief mention of a “Default event delay - Only so many events can be triggered per second” but no details on how many that is.


There should be a link somewhere in there to http://wiki.secondlife.com/wiki/LSL_Delay .. will have to see where things are linking now! (eta: fixed)
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
11-13-2009 14:03
From: Kayaker Magic
In llSetTimerEvent there is a brief mention of a “Default event delay - Only so many events can be triggered per second” but no details on how many that is. In the LSL Wiki it is suggested that you can't get more than about 25 events per second, so a rate of less than 0.04 has no real effect. However, since many LSL Library calls have a 0.2 second delay built in, I've rarely been able to get more than 5 events per second, so a rate of 0.2 is the smallest I normally use.

To detect multiple object names you have to leave the name field "" which detects all objects. If you have a shorter list than that, you must check for them yourself. For example:

llSensorRepeat( “”, “”, PASSIVE, 50, PI,0.2);
. . .
sensor(integer num)
{
while(--num>=0)
{
if (llDetectedName(num)==”wall”)
llOwnerSay(“found a wall”);
if (llDetectedName(num)==”floor”)
llOwnerSay(“found a floor”);
}
}

Chances are, the sensor is going to detect a lot of things on every sweep unless it's on a vacant sim. That's going to add up to a lot of script time, probably losing you friends on the sim.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
11-13-2009 14:09
From: Nyx Alsop
How do I detected Multiple object names I tried || but didn't work
You don't specify a name in the llSensorRepeat function and in the sensor event handler you check the names, say:
CODE
llSensorRepeat( "", NULL_KEY, AGENT, a_Range, a_Arc, a_Rate );
sensor( integer n )
{
integer j;
for ( j = 0; j < n; j++ ) llOwnerSay( llDetectedName(j)+" is an agent");
}
_____________________
From Studio Dora
Viktoria Dovgal
Join date: 29 Jul 2007
Posts: 3,593
11-13-2009 14:10
From: Rolig Loon
Chances are, the sensor is going to detect a lot of things on every sweep unless it's on a vacant sim. That's going to add up to a lot of script time, probably losing you friends on the sim.

A kinder way to do the timer thing might be a round robin arrangement, fire off a sensor for the next wanted name in the sensor/no_sensor events.