|
Tufif Kraft
Registered User
Join date: 4 Nov 2006
Posts: 64
|
04-21-2007 09:34
Hi, I'm new to using lists and I'm wondering if it is possible to remove something from one without clearing the whole thing. I haven't seen any mention of this online, but I also haven't seen anything saying it can't be done, so I'm going to hope that it can. Specificly, I am creating 2 phantom objects. When an avatar walks into the 1st object, I want the avatar's name (or key) added to a list as a string. When the avatar walks into the 2nd object, I want the avatar's name (or key) removed from the list, but leave on the lists the names (or keys) of any other avatar who has been in the 1st object. Can this be done in lsl? Thanks in advance for the help!
|
|
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
|
04-21-2007 09:40
Yes. You need to use both llListFindList (to check where if anywhere the item you want to remove is) and llDeleteSubList (to remove it). Something like the following... list remove_from_list(list original, list item) { integer pos = llListFindList(original, item); if (pos != -1) { original = llDeleteSubList(original, pos, pos); } return original; }
and call it with myNewList = remove_from_list(myOldList, [itemToRemove]);
Note that you call the function with the item to remove being a list - this helps make it generic, so the item could be an integer, a string, a float or whatever. If you always know the type of what you are searching for it can be simpler.
_____________________
http://ordinalmalaprop.com/forum/ - visit Ordinal's Scripting Colloquium for scripting discussion with actual working BBCode!
http://ordinalmalaprop.com/engine/ - An Engine Fit For My Proceeding, my Aethernet Journal
http://www.flickr.com/groups/slgriefbuild/ - Second Life Griefbuild Digest, pictures of horrible ad griefing and land spam, and the naming of names
|
|
Tufif Kraft
Registered User
Join date: 4 Nov 2006
Posts: 64
|
04-21-2007 09:48
Perfect! Now I can't wait to get home and try it 
|