Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

List variable questions

Bluestyle Baxton
Registered User
Join date: 27 Oct 2008
Posts: 1
11-02-2008 01:51
Basically i can add an item to a list variable, i have the item in a string variable and need the ListItemDelete function to remove the item from the list. Heres my code:

string name = llKey2Name(ToucherID); // get the name of the toucher that it represents

//Test to see if name is already registered (already in the list)
if(llListFindList(gWhoRegistered,[name]) == NOT_FOUND_IN_LIST)
{
list newList = ListItemDelete(gWhoRegistered, [name]); // removes name from the list

llSay(0,"You have DEREGISTERED from this Lecture, " + name + ".";);
}

My list variable is called gWhoRegistered, and i basicalyl just need to remove whatever is stored in the "name" string variable from the list. Can some 1 please give some advise?

Also, does anyone know if it is possible to extract the items from a list variable into a notecard? I think this may not be possible? otherwise anyway of IM'ing the list items to an avatar?

Cheers
Very Keynes
LSL is a Virus
Join date: 6 May 2006
Posts: 484
11-02-2008 03:07
This should help

CODE


list gWhoRegistered;
string name;

default
{
touch_start(integer total_number)
{
integer x;
name = llDetectedName(0);
// is this person already in the list ?
if((x = llListFindList(gWhoRegistered, [name])) == -1)
{
// No so add them
gWhoRegistered += name;
llSay(0, name + " Has been registerd");
}
else
{
// They are so remove them
gWhoRegistered = llDeleteSubList(gWhoRegistered, x, x);
llSay(0, name + " Has left the group");
}
// Send the new list to my owner via IM
x = llGetListLength(gWhoRegistered);
while(--x >= 0)llInstantMessage(llGetOwner(), llList2String(gWhoRegistered, x));
}
}



It is not possible to write to a notecard in SL sorry :)

You may also find my dbms system useful if you are treating lists as a database, look at this post for more info