Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Problem with llSensorRemove

Daisy Rimbaud
Registered User
Join date: 12 Oct 2006
Posts: 764
07-26-2007 13:07
I don't understand this at all. I've been putting in some debug-type llSay commands to track the execution of my code, and this is what is happening:

1) llSensorRepeat is called with a 1 second scan time.
2) The first line of the Sensor event is an llSay for tracking purposes.
3) I call llSensorRemove in a listen event.
4) The line after that is another llSay, which executes.
5) I then get the llSay from the Sensor event.

But I canceled the sensor! Why does it execute one more time? Is there a delay in llSensorRemove?
Milambus Oh
Registered User
Join date: 6 Apr 2007
Posts: 224
07-26-2007 13:28
Objects do not "hear" themselves. So your listen code is not executing.
Daisy Rimbaud
Registered User
Join date: 12 Oct 2006
Posts: 764
07-26-2007 13:42
No, it's listening to me.

But I found the answer. Sensor repeat calls are queued, and it can be that some stick in the queue after llSensorRemove is called. One has to add an extra variable to track if the sensor is supposed to be running or not.
Shadow Subagja
Registered User
Join date: 29 Apr 2007
Posts: 354
07-26-2007 15:10
Yeah any time you initiate something to call an event handler you have to assume it happens out of order. So the easiest way do deal with that would be:

FROM:

touch_start(int num)
{
llSensor()
stuffForAfterSensor();
}

sensor(){
llSay("one";);
}

TO:

touch_start(int num)
{
llSensor()
}

sensor(){
llSay("one";);
stuffForAfterSensor();
}

That will chain your functionality so it occurs in the expected sequence. I'm not sure if that is useful or not for you though.