Jump to content

Object Scanner & Notify


CandiZazzles
 Share

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

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

Recommended Posts

I've been working on a script for a personal project but can't seem to get it right

I need it to auto scan the sim for a certain object prim name as soon as it rezzes and I would like it to notify me via local with a TP to the exact location of the prim found even if i am off of the sim that the "scanner" is at. 

Any help or advice would be helpful :)

default
{
	touch_start(integer obj)
	{
		llSensor("",NULL_KEY,PASSIVE|ACTIVE,20.0,PI);
	}
	
	sensor(integer num_detected)
	{
		integer i;
		string display = "";
		
		for(i = 0; i < num_detected; i++)
		{
			string name;

			name = llDetectedName (i);
			// or ..= llToLower (llDetectedName(i)); for caseless search
			
			if (llSubStringIndex(name, "SPECIAL OBJECT") == 0) // starts with 'SPECIAL OBJECT'? (or != -1 for anywhere)
			{
				display = name + " " + (string)llDetectedPos(i) + "\n" + display;
			}
		}

		if (display != "")
		{
			llOwnerSay (display);
		}
		else
		{
			llOwnerSay ("No SPEICAL OBJECT's found in " + (string)num_detected + " objects!");
		}
	}
	
	no_sensor()
	{
		llOwnerSay("Nothing?");
	}
}

 

Link to comment
Share on other sites

Unsure what you're attempting to do, but as Profaitchikenz Haiku said, you need to scan continously- the code you have is a one shot affair.

 

Also, there is no need to gather all the info of nearby objects and then look for a specific name, just scan fot that name to begin with. That is what the first parameter of those function calls are about.

 

 

Link to comment
Share on other sites

Yes, the object needs to continuously keep scanning even after it finds the certain object. The name that its searching for would never change.. and I need a function to send a landmark to the location where it found the prim even if I am away off of the sim.

Link to comment
Share on other sites

something like this...?

this will send a clickable TP link to the object every 30 seconds..

you could make a list and a toggle to only be notified once per obj tho :)

 

vector pos;integer num;string region;integer k;key id;default{    state_entry()    {     region = llEscapeURL( llGetRegionName() );    }    touch_start(integer obj)    {      id = llDetectedKey(0);      if(id == llGetOwner() )     {         k = !k;        if(k)        {         llOwnerSay("ON");         llSensorRepeat("SPECIAL OBJECT", "",PASSIVE|ACTIVE, 20.0, PI, 30.0);        }        else        {  llOwnerSay("OFF"); llSensorRemove();}      }    }    sensor(integer num_detected)    {        num = num_detected;        integer i;        for(i = 0; i < num_detected; i++)        {         pos = llDetectedPos(i);         llInstantMessage( llGetOwner(), "\nClick link below to Teleport to SPECIAL OBJECT         \n secondlife:///app/teleport/" + region +          "/"+(string)llRound(pos.x)+ "/" +(string)llRound(pos.y)+ "/" +(string)llRound(pos.z));         }    }    no_sensor()    {     llOwnerSay ("No SPEICAL OBJECT's found in " + (string)num + " objects!");    }}

 

Link to comment
Share on other sites


CandiZazzles wrote:

Thanks Xiija for your help! :catvery-happy: 

The only problem I see with that script is its searching for any owner by the name of the certain prim. I'm trying to make it to where it will only search for my objects and no one elses. 

In that case, you'll need to filter the results in your sensor event with an extra if test to ask

if (llGetOwnerKey(llDetectedKey(0) ) == llGetOwner() )

to eliminate all detected objects that are not yours.  Of course, that means the results of the no_sensor event will not always be true, since no_sensor will only fire if there are no objects of any kind detected. If it's important to have that message, you'll have to put a new flag in the sensor event to let you know when no detected objects pass the new filter.

Link to comment
Share on other sites

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