Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Notecard String listens & removes?

Kobalt Bigbear
Registered User
Join date: 26 Sep 2009
Posts: 1
12-23-2009 08:33
Howdy there,
I've been attempting to build a script, but I'm a mere beginner and am having trouble finding the information I need. (Mainly, because I'm so new to scripting that I don't really know what the functions I need are called, to find them properly in the wiki.)

What I'm trying to do is:
Write a script that loads a list of names from a notecard. Then, listening to a specific channel, if the script hears a name off the notecard it removes it from the stored list of names. After a while, the avatar can touch the prim and it will print out a list of the names it hasn't heard.

I've found several examples of reading from a notecard, so I think I can figure that out. But I'm at a loss for figuring out how to store the information in script memory, and then remove the information the prim hears from the list? Can anyone point me in the right direction, or perhaps might have an example I can study? Thank you kindly for any assistance!
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
Rough outline...
12-23-2009 08:45
Read the strings from the notecard, and put them in a List.

The, when you hear a string in chat, search the list for that string. The find function will give you an "index", which is a number telling you which element in the List you found. The first one is element 0.

Remove it. (Note that you cannot remove it from the notecard.) I think you can use the "index" and Delete or Remove taht individual element.

Look in the Wiki for List functions. There are a lot of them, named things like llFindListInList() and so on.

Note that List operations are a little slow and use more memory then they should. Since you are a beginner, you perhaps shouldn't worry about that. Get it working first.

Have fun. That's why a lot of us are here 8-)
_____________________
So many monkeys, so little Shakespeare.
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
12-23-2009 11:02
Create a list from the notecard names, in the dataserver event....

if (!EOF)
{
mylist += data;
}


Use llListFindList() to find entries:

integer i = llListFindList(avatarName);

Use this function I found on the wiki to delete a single item from a list

list ListItemDelete(list mylist,string element_old) {
integer placeinlist = llListFindList(mylist, [element_old]);
if (placeinlist != -1)
return llDeleteSubList(mylist, placeinlist, placeinlist);
return mylist;
}
Pete Olihenge
Registered User
Join date: 9 Nov 2009
Posts: 315
12-23-2009 12:49
integer i = llListFindList (mylist, [avatarName]);

Fixed, I think.