LlListFindList
De DigiWiki.
list numbers = [1, 2, 3, 4, 5]; default { state_entry() { integer index = llListFindList(numbers, [3]); if (index != -1) { list three_four = llList2List(numbers, index, index + 1); llOwnerSay(llDumpList2String(three_four, ",")); // Object: 3,4 } } }
//You can also search for two items at once to find a pattern in a list list avatarsWhoFoundMagicLeaves = ["Fire Centaur","Red Leaf"]; default { state_entry() { integer index = llListFindList(avatarsWhoFoundMagicLeaves, ["Fire Centaur","Red Leaf"]); if (index != -1) { list output = llList2List(avatarsWhoFoundMagicLeaves, index, index + 1); llOwnerSay(llDumpList2String(output, ",")); // Object: Fire Centaur, Red Leaf } } }
An easy way to see if an item exists in a list...
if(~llListFindList(myList, (list)item)) {//it exists //This works because ~(-1) == 0 //It saves bytecode and is faster then doing != -1 }