Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Less Strict Sensor

Michael Martinez
Don't poke me!
Join date: 28 Jul 2004
Posts: 515
02-15-2005 19:15
Any way to make a sensor less strict?

So you want to find Michael Martinez, so instead of searching the whole name with upper/lower case, just do find michael and it will find Michaels in the area...

Thanks.. :)
Jason Keegan
Registered User
Join date: 20 Apr 2004
Posts: 26
02-16-2005 04:11
Heya,

Maybe there is a better way to do this, but this will do what you wanted.



CODE



string command = "find"; //This is your command, The listen will make sure you said this before the name of the person you are looking for. 'find Michael'



integer listenID; //Listen tag

string To_Find; //Person you wish to find.


default
{
state_entry()
{
//Set up the listen on channel 25
llListenRemove(listenID);
listenID = llListen(25, "", llGetOwner(), "");
}

listen(integer channel, string name, key id, string msg)
{
//check owner actually gave the command
if(llSubStringIndex(llToLower(msg), llToLower(command)) == 0)
{
//Give To_Find the same value as that of the name you are searching.
To_Find = llGetSubString(msg, llStringLength(command) + 1,llStringLength(msg));
//Start sensor
llSensor("", "", AGENT, 96, PI);
}
return;
}
sensor(integer num_detected)
{
//creat a loop to check everyone returned in scan
integer i;
for(i = 0;i < num_detected;i++)
{
//This is the full name of the person found in scan making it lowecase
string full_name = llDetectedName(i);


//This will strip the first name from the full_name
string first_name = llGetSubString(full_name,0,llSubStringIndex(full_name," ") - 1);

//compare it to To_Find
if(llToLower(first_name) != llToLower(To_Find)) return;
llSay(0, first_name + " has been found at " + (string) llDetectedPos(i));
}
}
on_rez(integer start_param)
{
llResetScript();
}
}






If its no good, dont shoot me, just trying to help :)

- Jason.
Michael Martinez
Don't poke me!
Join date: 28 Jul 2004
Posts: 515
02-16-2005 09:25
Thanks!