LlList2ListStrided

来自人工智能助力教育知识百科
跳转至: 导航搜索

Template:Needs Translation/


函数名
Function: list llList2ListStrided( list src, integer start, integer end, integer stride );
参数:

list src integer start – start index integer end – end index integer stride – number of entries per stride, if less than 1 it is assumed to be 1

返回值:

返回一个条纹列表中所有索引是从开始到结束范围中跨步的倍数的条目的列表。

注意事项
*如果开始或结束都超出了界限,脚本将继续执行,而不会出现错误消息。
  • 当 start is past end (大约是: start > end)时,start & end 将不会形成排除范围,相反,它将表现得好像 start 是 zero,end 是 -1。
示例
示例一
list mylist = [0,1,2,3,4,5,6];
list result_a = llList2ListStrided(mylist,0,-1,2); //start at first item in list, go to the end, return every 2nd item
//result_a == [0,2,4,6]
 
list result_b = llList2ListStrided(mylist,1,-1,2); //start at second item in list, go to the end, return every 2nd item
//result_b == [2,4,6]
 
list result_c = llList2ListStrided(mylist,2,-1,2); //start at third item in list, go to the end, return every 2nd item
//result_c == [2,4,6]

示例二

list menu = ["1", "one", "2", "two", "3", "three"];
default
{
    state_entry()
    {
        llListen(10, "", llGetOwner(), "");
    }
    touch_start(integer detected)
    {
        list buttons = llList2ListStrided(menu, 0, -1, 2);
        llDialog(llDetectedKey(0), "choose a number", buttons, 10);
    }
    listen(integer channel, string obj, key id, string message)
    {
        integer index = llListFindList(menu, [message]);
        if (index != -1)
        {
            llOwnerSay("you chose " + llList2String(menu, index + 1) + " (" + message + ")");
        }
    }
}
相关函数
相关事件