Jump to content

Still lost on detecting objects


MrDarkWolf
 Share

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

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

Recommended Posts

I have been trying to figure out how to get a script to detect when a scripted object is rezzed and not to have the message keep repeating itself. Though the objects that I am wanting to detect will have the same name each time one rezzes, I am looking to have one message per each occurrence. Help advice will be greatly appreciated.

Link to comment
Share on other sites

Maintain a list of objects detected. On each detection (llSensor, rezzed object phoning home, etc) check the name against the list of previous detections. If new, add it and inform, otherwise skip quietly by.

You will have to use the name and not the detected key, because the key will be unique for each instance inworld, but the name will not. In case you're also going to see objects of the same name coming from other people that you wish to ignore, check the object owner as well.

  • Like 1
Link to comment
Share on other sites

Stuff a script in the objects which should be rezzed, then add an
on_rez(integer startparam) {;}
event and inside it add the line
"llRegionSay(12345,"I am rezzed." );
This line will execute only once.

Next, make your other object listen on channel 12345 and if it hears "I am rezzed" it will also receive the name and the UUID of the rezzed object. Now you know which object is rezzed.

Edited by Fritigern Gothly
  • Like 1
Link to comment
Share on other sites

If Fritigern's suggestion of having the objects announce themselves when they're rezzed is impractical, detect the objects by name, but keep a list of their keys. Each object rezzed will have the same name but a unique key, so when you detect an object check its key against a list to see if you've seen it before and, if not, send the message and add its key to the list.

The next problem is figuring out a way to recognise that a listed object has gone away so you can remove its key from the list, otherwise the list will keep growing until it crashes the script.

  • Like 1
Link to comment
Share on other sites

What it is that I am making an item to detect when a breedable drops, or rezzes, its offspring. Each time it happens, they have the same name but different UUIDs. I am wanting for it to notify me of when each one drops, no matter if I am on the same sim or not, but without continuously spamming me of it. 

Link to comment
Share on other sites

2 hours ago, Fritigern Gothly said:

Stuff a script in the objects which should be rezzed, then add an
on_rez(integer startparam) {;}
event and inside it add the line
"llRegionSay(12345,"I am rezzed." );
This line will execute only once.

Next, make your other object listen on channel 12345 and if it hears "I am rezzed" it will also receive the name and the UUID of the rezzed object. Now you know which object is rezzed.

There is no stuffing a new script in the objects that I want to detect. They are no mod and they are not my creation.

Link to comment
Share on other sites

I'm not familiar with the mechanics of breedables, but I presume you'll want to follow Profaitchikenz and KT's advice to maintain a list of detected objects and check against that on each iteration of your sensor. If the uuid isn't already in the list, then we assume it's a freshly rezzed object. So send the announcement out and also store the uuid in a list. The next time the sensor fires, it will follow the same sequence: for each uuid the sensor detected, check to see if it's already in the list. If so, do nothing. If it's not in the list, it's new, so announce and add the uuid to the list. Lather, rinse repeat.

You'll want to also setup a controlled environment for this where the breedable is corralled in an circular area that is the same radius as the sensor range. Try to have no other objects inside that range except for the sensor and the target breedable. That way you minimize the number of objects you need to process on each sensor pass.

Link to comment
Share on other sites

Now that the OP has given more details of their problem the biggest issue I can see is that llSensor can only detect up to 16 objects, so if these little critturs breed like the proverbial then the fibonacci sequence is going to pass 16 in next to no time.

That said, from practical experience when I had an island and a friend had Meeroos up on one of the platforms, they were quite restrained and I don't think ever exceeded a dozen in number.

One option is to have an object that tracks any breedables about to give birth, or in the case of Meeroos, stays close to a nest.

 

ETA

Just thinking about it, this is a perfect case for llGetParcelPrimCount, you only need to start the sensing action when the prim count increases, at which point you could have a series of prims using llSensor to take a census within their radius and report what they find to a central script, which does the filtering to weed out uuids it has already been advised of and concentrate on the newcomers.

Edited by Profaitchikenz Haiku
  • Like 2
Link to comment
Share on other sites

Thanks for the advice everyone. But, that still doesn't really help me understand where I can get it to send me a notification once per instance, instead of constantly sending out the notification. As stated previously, that is what I am looking for. 

Link to comment
Share on other sites

49 minutes ago, MrDarkWolf said:

Thanks for the advice everyone. But, that still doesn't really help me understand where I can get it to send me a notification once per instance, instead of constantly sending out the notification. As stated previously, that is what I am looking for. 

A cross-region message can be sent with llInstantMessage. It will show up in your local chat.

The "per instance" part has already been explained. Keep a list of known instances, and only send a notification if the instance detected by a sensor is not on the list.

Edited by Wulfie Reanimator
Link to comment
Share on other sites

52 minutes ago, MrDarkWolf said:

Thanks for the advice everyone. But, that still doesn't really help me understand where I can get it to send me a notification once per instance, instead of constantly sending out the notification. As stated previously, that is what I am looking for. 

when you say once per instance do you mean an instance is the first of the name then ignoring any same named offspring dropped subsequently ?

like dropped offspring: BLUE, GREEN, BLUE, GREEN, RED, BLUE, BLUE, RED, GOLD, BLUE, PURPLE, RED ... 

then you get a message for the first instance of BLUE then GREEN then RED etc etc, the second/third/other same named instances you don't get a message for ?

 

if so then as others mentioned llSensor is the way to go. On first BLUE found, add BLUE to the list. Ignore any further dropped BLUE thereafter for the session. Same with GREEN, RED, etc

we need some kind of session (time period) else information will go stale

a way to do this is to treat each time you login as the beginning of a new session.  On script detecting that you have logged in, start sensor. Detect the current dropped offspring, build a list of first instances present: RED, GREEN, BLUE, etc.  Send this list to yourself as a instant message

then sensor script only adds the first instance of any named offspring not already on the list and messages you

when the sensor script detects that you have logged off, it stops sensing. And waits for you to log in again

 

  • Like 1
Link to comment
Share on other sites

3 hours ago, Mollymews said:

when you say once per instance do you mean an instance is the first of the name then ignoring any same named offspring dropped subsequently ?

like dropped offspring: BLUE, GREEN, BLUE, GREEN, RED, BLUE, BLUE, RED, GOLD, BLUE, PURPLE, RED ... 

 

Let's use this as an example. There are a set of horses (1 male and 4 females) within the 10m of the object's detecting range. When the females give birth, they drop objects called "Hellsent Horse Bundle" (of course not an actual breedable, just an example), but the UUIDs are different and random. Each female drops 1 of these bundles on average of 8 days, with about 2 days in between each female (female #1 drops, 2 days later will be female #2, etc.). The message is to be sent out once each time one of the females gives birth, even when I'm offline. 

  • Thanks 1
Link to comment
Share on other sites

Store the last UUID for which you sent the message (start with an empty list, let's call it "seen" for now).

When the sensor detects "numFound" objects named "Hellsent Horse Bundle" within range, check each detected UUID against the list of UUIDs already sent using llListFindList(seen, [llDetectedKey(loop-counter)] ) which will return > -1 if it's in the list. (loopCounter runs from 0 to num_found - 1);

If it isn't in the list, it's new; Add the UUID to the list, send the message that "Hellsent Horse Bundle" has been spotted.

The next time the sensor triggers and detects objects within range, it will check each detected UUID against the list of sent UUIDs and not inform you for each UUID that it finds is already in the list.

At intervals of perhaps a month, you'll probably want to empty the list of UUIDs to avoid running out of memory. 

ETA I can't add a code block to a post I've already created? How much worse can things get?

sensor (integer num_found)

{

    integer ii;

    for( ii = 0; ii < num_found; ii++)

    {

         if( llListFindList(seen, [llDetectedKey(ii)]) == -1) // add the key to seen, send the IM, else do nowt

    }

}

Edited by Profaitchikenz Haiku
clarity
  • Like 2
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1230 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...