Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llGetListLength issues

Serina Darkholme
Registered User
Join date: 11 Jan 2005
Posts: 35
07-18-2005 10:15
hmm, not sure if its my bad coding or a bug or what.
i have 10 lists all named incrementally, ie names1, names2, etc etc
(sorry, i dont know how to do code boxes)

integer listnumber = (integer)(llFrand(11 - 1) + 1);
string workinglist = ("names"+(string)listnumber);
integer listentries = llGetListLength(workinglist);


so what im trying to do is get the code to pick a random list and give me the length of it.

but i get "ERROR : Function call mismatches type or number of arguements" for the word in the brackets of the llGetListLength

i really need help here, as far as i can see it SHOULD work.

TIA
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
07-18-2005 10:24
Im afraid how you're going about doing this won't work :(
LSL doesn't allow you to "generate" variable names - I cant say llGetListLength("myList1";) because "myList1" is a considered a string, not a variable name, by the compiler. To make a box of values (a list of lists) I recommend using something like a multidimensional array.
Using the API I just linked to, you could do something like this:
list myMultidim;
myMultidim = setElementAt(myMultidim, ["A", "B", "C"], [0]);
myMultidim = setElementAt(myMultidim, ["D", "E", "F"], [1]);
This would create a list, containing two lists at indexes 0 and 1.
To choose a random list within myList, the code is very similar.
integer numLists = llGetListLength(myMultidim);
integer randIndex = (integer) llFrand(numLists);
list randmList = getElementAt(myMultidim, [randIndex]);

Hope this helps :D
==Chris
_____________________
October 3rd is the Day Against DRM (Digital Restrictions Management), learn more at http://www.defectivebydesign.org/what_is_drm
Serina Darkholme
Registered User
Join date: 11 Jan 2005
Posts: 35
07-18-2005 10:31
thanks for the quick reply, i just needed to know if it was me or the LSL :)
now i know, i can backup a little and try a different route, i dont think my script is complex enough to have to use your API :)

thanks again