Template:Needs Translation/
函数名
|
Function: integer llListFindList( list src, list test );
|
参数:
list src – what to search in (haystack)
list test – what to search for (needle)
|
返回值:
返回 src 中第一个 test 实例的整数索引。
|
注意事项
|
*执行严格的类型匹配和大小写敏感性。
"1" != 1
"1.0" != 1.0
1 != 1.0
"a822ff2b-ff02-461d-b45d-dcd10a2de0c2" != (key)"a822ff2b-ff02-461d-b45d-dcd10a2de0c2"
"Justice" != "justice"
- 如果 test 是一个空列表,则返回的值是0而不是 -1。
|
示例
|
示例一
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
}
}
}
|