Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

looking for help-voice activated llSensor

Samuel Biggles
So Shallow Sam
Join date: 17 Aug 2004
Posts: 54
01-26-2005 08:00
I am stuck, i have attempted to build a Sensor event which searches for the name i say, but it is just a no go, can someone please show me a script which does the following
listens for your avatar
searches the text said for other avatars name
says the name that it has found.
and please explain to me how it works exactly.
_____________________
Life is like a box of chocolates- no it isn't, life isn't in a box, and there are chocolates in it, but chocolates are small and brown and sweet tasting and life may or may not even exist so what you've said there is nonsense you dopey bastard.
Jason Keegan
Registered User
Join date: 20 Apr 2004
Posts: 26
01-26-2005 10:42
Think this what your after.


CODE


list found;//list for everyone found in scan

integer o_listen; //Owner listen


string toFind; //name of the person your wanting to scan for.

default
{
state_entry()
{
//owner only listen on channel 99
o_listen = llListen(99, "", llGetOwner(), "");
}

listen(integer channel, string name, key id, string msg)
{
//When a message is heard from the owner its will fire off the sensor. which is searching for ALL avatars in its range
llSensor("", NULL_KEY, AGENT, 96, PI);

//Clear the found list so as your scanner can be used with out reseting script
found = [];

//set 'toFind' the same value as msg, In this case it will be the name of the person your looking for.
toFind = msg;
}
sensor(integer total_num)
{
//create a loop to be sure to add EVERYONE found in the scan to the list
integer i;
for(i=0;i<total_num;i++)
{
//this is where it adds them to the list in lower case easier to compare
found += llToLower(llDetectedName(i));

//This will give the integer 'pos', The same value as that of the position of 'toFind' in the list 'found'.
integer pos = llListFindList(found, [llToLower(toFind)]);

//If 'toFind' is not in the list it returns the value of -1
//So
if(pos > -1)
{//If the value is greater than -1 it means 'toFind is in the list.

//Announce that 'toFind' has been found and also add the position of the AV.
llSay(0, toFind+ " has been found at " + (string) llDetectedPos(i));
}
}
}


on_rez(integer start_param)
{
//Reset script on rez.
llResetScript();
}
}




to get this to work simply say '/99 AVATAR' replacing AVATAR with the name of the person your after.

Hope that explains it well enough, if not give me a shout in game.

- Jason
Stinky Queso
Second Life Resident
Join date: 29 Nov 2004
Posts: 53
01-26-2005 15:02
whats up with the list usage? if the command was /find on channel 0, why not just
CODE

string find;
string found;

if(llGetSubString(message, 0, llSubStringIndex(message, " ") - 1) == "/find")
{
find = llGetSubString(message, llSubStringIndex(message, " ") + 1);
llSensor("", "", AGENT, 96, PI);
}

//then in the sensor just have it cycle through names, and put this in the sensor

if(llSubStringIndex(llToLower(llDetectedName(i)), find) != -1)
{
llWhisper(0, llDetectedName(i);
found = llDetectedName(i);
}


sorry if I screwed up somewhere (wrote this in internet explorer..), would this be faster or slower than finding the name amongst a list? this is what I do, seems to work find and its not as messy (I think).

:ninja: BTW, this will listen for "/find" and take the string after that, search all sensored names and pick out the one that matches. This will work for first and last names. If two targets are found I believe that this will get the closest (not sure)