Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Basic list add/remove

pi Mip
Registered User
Join date: 18 Jan 2007
Posts: 20
04-14-2007 09:01
For some reason, after searching for an hour, I can't find a simple example of how to add an item to a list run-time, and then iterate through it.

I assume this is possible, right?
Sys Slade
Registered User
Join date: 15 Feb 2007
Posts: 626
04-14-2007 09:07
http://rpgstats.com/wiki/index.php?title=List

To add an element, you can use:
CODE
mylist += [new_item]

CODE
mylist = mylist + [new_item]

or
CODE
myList = (myList=[]) + myList + new_item

which apparently saves memory.

To iterate through a list, simply get the list length using llGetListLength(list_name) and use that in a for or while loop.
pi Mip
Registered User
Join date: 18 Jan 2007
Posts: 20
04-14-2007 09:15
Oh man. Great help.

I guess I was confused when searching the boards cuz it says "php" script, so I assumed people were talking about php.

Thanks!
Sys Slade
Registered User
Join date: 15 Feb 2007
Posts: 626
04-14-2007 09:30
The reason we use the php tag is because the code tag is so naff :p

CODE
 mylist += [new_item] 

vs
CODE
 mylist += [new_item]