Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Getting llDetectName to check against a Notecard

Keno Pontoppidan
Registered User
Join date: 20 Oct 2005
Posts: 75
02-01-2006 10:32
I was just wondering how I could make llDetectName to check against a list of names in a notecard rather than having to invidually type llDetectName with each persons name in the script.
Thanks

Keno
Fiona Fielding
Registered User
Join date: 21 Jun 2005
Posts: 24
02-01-2006 10:57
Load all the names from the notecard into a list using the dataserver functions and you can just check against that.
Rizado DaSilva
Merchant
Join date: 12 May 2005
Posts: 30
02-01-2006 11:08
Hmmm, I just started learning notecards yesterday ::grins:: but, I would thing that something along the lines of...

#note_card
Rizado DaSilva=This is something about Rizado
Keno Pontoppidan=This is other stuff about Keno
CODE

dataserver(key query, string data) {
string check_name;
string check_data;

if (data == EOF) {
return;
} else {
integer i = llSubStringIndex(data, "=");
check_name = llGetSubString(data, 0, i - 1);
check_data = llGetSubString(data, i + 1, llStringLength(data) - 1);
if (check_name == llKey2Name(llDetectedKey(0))) {
myvar1 = check_name;
myvar2 = check_data;
}
line = line + 1;
llGetNotecardLine("notecard", line);
}
Of course, you'd have to call the notecard too, haven't checked this code but it should be close I think and it's not loading a list, would just read the notecard and if it finds the name loads the info.

Of course, a list would be faster, but, if you don't need speed ::shrugs:: Someone else might be able to do this a lot better, as I said, I only started doing notecards yesterday and am still a newbie programmer.

=R
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
02-01-2006 11:15
Assuming the notecard doesn't have hundreds of names, I would read the entire notecard into a list when the script starts, and then check if llDetectedName(0) is in the list.

Rizado, there's one small problem with your code snippet - llDetectedName(0) only works in the function that did the 'detecting' - i.e. a touch, collision or sensor handler. AFAIK, that function will return an empty string when called in the dataserver handler like you did. Which si easy to solve - call it in the touch/whavere handler, and save that name to another global, and then use that global for teh comparison in the dataserver handler.