Jump to content

Sensor in diffrerents ranges


Faustnw
 Share

You are about to reply to a thread that has been inactive for 2725 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hi,


I wonder if is it possible to launch properly several sensors (or sensor repeats) in pararel. My script detects and display the number of prims in a specific area. Preciesly, it will detect the number of prims which are between xx and xx m. The script will also detect and display all xx seconds

The number of prims doesn't create me difficulties. I just need to make a substract. The only problem is how to launch not an only range values, but multiples range values at the same time (a list of range values)

I tried :

-llSensor loop, llSleep and reset the script (and the variables) : Randomly works. It display nothing like it display the second first range values and his numbers of prim but not the others
-Use a llSensorRepeat, create a second state, enter in this state and comeback to default state : Display the next range value and the number of prims in here

Here is the script of the first solution. In this script, I choose to detect the number of prims which are under 5m, between 5 and 10m and between 10 and 50m :

list areas = [5,10,50];
list primList = [];
integer previousPrimsNumber = 0;
integer primsNb =0;
integer firstIndex = TRUE;
integer areaID=0;

default
{
state_entry(){
state countPrims;
}

}

state countPrims
{
state_entry()
{
integer i;
for(i=0;i<llGetListLength(areas);i++){
llSensor( "","", PASSIVE, llList2Integer(areas,i), PI);
}
}

sensor (integer numberDetected)
{
if(firstIndex){
previousPrimsNumber = numberDetected;
primsNb = numberDetected;
firstIndex=FALSE;
}else{
primsNb = numberDetected-previousPrimsNumber;
previousPrimsNumber += primsNb;
}
primList = llListInsertList(primList, [primsNb], llGetListLength(primList));
areaID++;
if(areaID == llGetListLength(areas)){
state displayState;
}
}

no_sensor()
{
llOwnerSay("Nothing here");
state displayState;
}
}

state displayState
{
state_entry()
{
integer j;
for(j=0;j<llGetListLength(zones);j++){
llOwnerSay("On "+(string)llList2Integer(areas,j)+" m: "+(string)llList2Integer(primList,j));
}
state waitState;
}
}

state waitState
{
state_entry()
{
llOwnerSay("Wait...");
primList = [];
previousPrimsNumber = 0;
primsNb =0;
areaID=0;
llSleep(5.0);
llOwnerSay("Reset");
state primsNbtate;
}
}

 I am open to any suggestions. Have a nice day !

Link to comment
Share on other sites

Only one sensor is active at a time, so don't set up several in a loop. Rather, after getting the results from one, call your next llSensor() from within the sensor() (or no_sensor()) event. Use a global variable to keep track of where you are in the sequence of sensor ranges.

[EDIT: Actually, though, the premise doesn't make sense. You can't specify an inner, excluded zone from the sensor results, so you may as well just always ask for the largest range of interest and in your script select the inner ranges from the results, which will always be the 16 or fewer nearest matches.]

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2725 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...