Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Controling rez in llSensorRepeat()

Garan Darkes
Registered User
Join date: 23 May 2006
Posts: 7
06-05-2007 01:58
Let's say I have a sensor system that uses llSensorRepeat() and rezzes followers for each avatar it detects... This is a security system that I'm currently developing. And it has the fancy touch of adorning people's heads with red countdown timers.(I know that makes it a lot more complex, but it's my artistic touch and I'm not willing to part with it :P). The trick comes in the fact that I only want the security system to rez ONE follower drone per detected avatar..

But the drones are also programmed to halt the timer and wait 10 seconds should the avatar leave the land and decide to come right back, so just doing a "when the avatar is no longer on sensor, reset the already_rezzed variable for that avatar" kind of trick isn't a possibility, simply because he'd get a second drone over his head when he returned. AND since my sensor is not set to 0.001 repeat rate to avoid unnecessary lag, avatars could also possibly leave and come right back before the next sensor swipe, thus avoiding having another drone rezzed on them. (Yes, I know it's a long and complex explanation.. Please bear with me as I do not wish to expose my script to public view) This is a security breach window that I do not want on my system..

So right now, it works in what I consider to be a very messy way. There's a timer in the script that regularly clears the "currently_detected" list. The drones send their target keys back to the security system via llRegionSay() each time before the timer does the next clear(every 4 seconds to be precise). (and even though the listen params are as tight as they can be, I realize this is very inefficient..) Every time, the timer event compares all elements in the "exceptions" list(the one that prevents another drone rez on said avatar key while it's in the list) to the ones in the currently_detected list. If an entry is found within exceptions that is not within currently_detected, then that entry is deleted from the exceptions list.. Basically the drones keep telling the main system that they're still alive and still hunting their target. Once that's no longer the case, the specified key is removed from the exceptions list and another drone will be rezzed on that avatar next time.

That's how I ensure that 2 drones are never rezzed on the same target, and since they use llRegionSay(), other security boxes can also hear them and will add the key to their exceptions list.

I ask.. Can anyone think of a better and simpler way to achieve this? I really hate how messy I had to make this, but I could think of no other solution.. Please note that sending a message before the drone dies is also not a solution.. Because messages are never certain to get through. If this happens with my current system, a second drone may be rezzed once in a blue moon.. But if removing the exception depended on it, that particular avatar would remain in exceptions forever, making them immune to the security.
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
06-05-2007 04:35
I'm sure I don't understand all this, but... what if a newly-rezzed follower's on_rez() handler does a one-time llSensor() for another follower within some very short range (perhaps twice the expected following error) and llDies() if it finds one? If proximity can't be tight enough to prevent mistaking a sensed follower on a different target, could the followers llSetObjectName() to something that uniquely identifies their targets?
Garan Darkes
Registered User
Join date: 23 May 2006
Posts: 7
06-05-2007 05:10
Thank you for your reply. That is certainly not a bad idea.. Though that just kills the additional drones, it doesn't prevent them from rezzing in the first place. That may work, except.. What's laggier? Sending a llRegionSay() every 4 seconds or rezzing and llDie()ing a drone every 4 seconds?
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
06-05-2007 05:15
Well, *if* I understand correctly (which is far from certain), you'd only rez the follower on the relatively rare event of an avatar popping back into sensor range, not every 4 seconds.
Garan Darkes
Registered User
Join date: 23 May 2006
Posts: 7
06-05-2007 05:49
Doh! Of course! It seems my brain was completely lost when I was reading your response.

I see what you mean now..

Revert back to setting the exceptions list based on avatar in sensor range. Make the follower set its name to the target's key, providing a unique ID.. If drone senses another with the same name as it has, make it llDie().

That's simple and yet brilliant.. And look at me making an uber complex and laggy workaround. I'm so glad I asked. Thank you VERY much for the suggestion!