Bo Grafta Posted March 26, 2020 Share Posted March 26, 2020 I have four lists. I want to select one of the four lists depending of a selection. How can I use a variable instead of the list name. This example does not work, but I want something like that: string ListName="T2"; string texture= llList2String(ListName, counter); Link to comment Share on other sites More sharing options...
Mollymews Posted March 26, 2020 Share Posted March 26, 2020 the best we can do is to create a wrapper function. Something like: //globals list t1; list t2; list t3; list t4; list getListByName(string name) { if (name == "T1") return t1; if (name == "T2") return t2; if (name == "T3") return t3; return t4; } ... string ListName = "T2"; string texture = llList2String(getListByName(ListName), counter); 1 Link to comment Share on other sites More sharing options...
KT Kingsley Posted March 26, 2020 Share Posted March 26, 2020 Are the four lists the same length? If so, you could concatenate them and add list number * individual list length to the index when accessing the items: // four lists of three items each, concatenated list my_list = [ "A", "B", "C", // list 0 "D", "E", "F", // list 1 "G", "H", "I", // list 2 "J", "K", "L" // list 3 ]; integer individual_list_length = 3; default { state_entry () { integer list_number = 1; // the list numbers run from 0 to 3 integer list_item = 2; // the items in each list are indexed 0 to 2 string item = llList2String (my_list, (list_number * individual_list_length) + list_item); // 1 * 3 + 2 = 5 llOwnerSay (item); // "F" } } 2 Link to comment Share on other sites More sharing options...
Bo Grafta Posted March 26, 2020 Author Share Posted March 26, 2020 (edited) Yes, they are the same length. I have considerd to make one list instead of four different en change the index, but first I wanted to know if it was possible to do it at the way I asked. Thank you verry much Mollymews, it was just what I was looking for! Edited March 26, 2020 by Bo Grafta 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Please take a moment to consider if this thread is worth bumping.
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now