|
Mod Faulkner
Registered User
Join date: 11 Oct 2005
Posts: 187
|
01-04-2007 22:57
I have script that keeps track of several functions using four list. The script performs similar function on all the lists. What I would like to know is if it is possible to use a list of list names to set up one user defined function to handle all of them. Something along the line of
llSearch(list which,string name,integer amount) { if(llListFindList(which,[name]) == -1) { which = which + name + amount; }
where "which" could be list_1, list_2, list_3, or list_4
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
01-05-2007 00:25
From: Mod Faulkner I have script that keeps track of several functions using four list. The script performs similar function on all the lists. What I would like to know is if it is possible to use a list of list names to set up one user defined function to handle all of them. Something along the line of
llSearch(list which,string name,integer amount) { if(llListFindList(which,[name]) == -1) { which = which + name + amount; }
where "which" could be list_1, list_2, list_3, or list_4 What you are describing isnt a list of lists, you are just passing a copy of the specific list in as a parameter called which. You will need to store the result back into the original list since LSL passes by value not by reference (hence the parameter being a copy). If your lists are large you may run in to stack problems. list SearchAndAdd(list which, string name, integer amount) { if(llListFindList(which,[name]) == -1) { which = (which = []) + which + [ name , amount ]; } return which; }
And used as MyList = SearchAndAdd(MyList, "Newgate Ludd",10);
|
|
Mod Faulkner
Registered User
Join date: 11 Oct 2005
Posts: 187
|
Thanks
01-05-2007 03:13
Thanks
|