Skip to content
lsl.devlsl.devLSL Dev

llList2ListStrided

function
Function syntax
list llList2ListStrided(
  1. list src,// Source strided list.
  2. integer start_index,// Zero-based start index (inclusive).
  3. integer end_index,// Zero-based end index (inclusive).
  4. integer stride// Number of entries per stride (defaults to 1 if less than 1).
);
Returns
list
Energy
10

Returns a new list containing the first element of every stride in the strided list src within the inclusive range from start to end.

Returns a list of all the entries in the strided list whose index is a multiple of stride in the range start to end.

How to use
list result = llList2ListStrided([], 0, 0, 0);
Example 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]
Example 2
7 collapsed lines
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);
}
9 collapsed lines
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 + ")");
}
}
}

If you want every second (or third, etc.) item in each stride returned, rather than the first, use llList2ListSlice instead.

Original wiki source

Some wiki templates and tables need their original context. View this article on the Second Life Wiki. Technical wording and examples are retained from the source; historical guidance may differ from current behavior.