Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

List issue

Knight Nootan
Registered User
Join date: 26 May 2008
Posts: 73
07-12-2009 11:58
I have a list that I add names to in the script via chat but how would I remove a name from the list? I have tried a few different ideas but none worked. Any help or direction will be appreciated!

Thanks!
Paul Wardark
Wait, what?
Join date: 10 Jan 2009
Posts: 383
07-12-2009 12:09
If you can post the script, we can see what the command is to remove names, or tell you how to add a command to do it.
_____________________
Knight Nootan
Registered User
Join date: 26 May 2008
Posts: 73
07-12-2009 12:17
here are the 2 states I am using. The first is to add a name to the list and the second will be to remove a name from the list.

state load
{
state_entry()
{
llListenRemove(handle);
llListen(0, "", NULL_KEY, "";);
}

listen(integer channel, string name, key id, string message)
{


llGetSubString(message,0,llStringLength(message));
av_list += (string)message;
llOwnerSay(message + " added!";);
state default;

}
}
state remove
{
state_entry()
{
llListenRemove(handle);
llListen(0, "", NULL_KEY, "";);
}

listen(integer channel, string name, key id, string message)
{


llGetSubString(message,0,llStringLength(message));
av_list -= (string)message;
llOwnerSay(message + " removed!";);
state default;

}
}


I was thinking since + adds to the list that - would remove, but I must be wrong.
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
07-12-2009 12:37
The function you want is llDeleteSubList or maybe llListReplaceList, depending on how you want to do it. Take a look at

and
.

You can save yourself quite a bit of scripting by collapsing your script into a single state, BTW. Instead of state load and state remove, just put your list maintenance functions in a single listen event in state default and use an if test to choose between them at run time.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
Knight Nootan
Registered User
Join date: 26 May 2008
Posts: 73
07-12-2009 13:16
OK, reading over those functions and now have a question. It looks as if it will only remove the line from the list you tell it. Is there a way to remove a name for example without knowing the exact line?
Viktoria Dovgal
Join date: 29 Jul 2007
Posts: 3,593
07-12-2009 13:23
You can use llListFindList to find the index to feed into llDeleteSubList. Yes, it's disgusting. With luck, the nausea will subside in time.
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
07-12-2009 13:30
I'm not sure what you mean. If you know what you want to remove, you just locate its position with llListFindList and then use llDeleteSubList to cut it out, like so...

CODE

integer WhereIs = llListFindList(MyList, ["Bad Data"]);
if (WhereIs != -1)
{
MyList = llDeleteSubList(MyList,WhereIs,WhereIs);
}


I think that's what you're asking. If not, ask again. :)
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
Knight Nootan
Registered User
Join date: 26 May 2008
Posts: 73
07-12-2009 13:42
That is exactly what I am trying to do, where I was getting lost was how to tell it to only remove that data, but now I see you can do it via an integer wich I didnt know.

Thanks!!!!!!!!