CODE
integer GET_CATEGORY = 302;
integer SET_CATEGORY = 303;
list CONSTANTS_AND_NAMES = [
// Constant //Name
GET_CATEGORY, "GET_CATEGORY",
SET_CATEGORY, "SET_CATEGORY"
//etc...
];
default {
state_entry() {
list constantNames = llList2ListStrided(CONSTANTS_AND_NAMES, 1, -1, 2);
integer i;
integer len = llGetListLength(constantNames);
for(i = 0; i < len; i++) {
llSay(0, llList2String(constantNames, i));
}
}
}
I kept attempting to extract only the string names in the CONSTANTS_AND_NAMES list but couldn't figure out why llList2ListStrided was only giving me the integer constants no matter what parameters I passed to it.
I IM'med ThinkTank (a scripting group) about it, and Francis Chung responded with the solution:
list fix = llList2List(CONSTANTS_AND_NAMES, 1, -1);
list constantNames = llList2ListStrided(fix, 0, -1, 2)
It seemed that llList2ListStrided was ignoring the start parameter passed to it. Francis' fix for my problem gave me the idea behind this generalized fix for llList2ListStrided:
CODE
list list2ListStrided(list src, integer start, integer end, integer stride) {
return llList2ListStrided(llList2List(src, start, end), 0, end, stride);
}
Basically, since llList2ListStrided is (currently) ignoring the start parameter, this function shifts src so that llList2ListStrided will work striding from element 0.
Even if llList2ListStrided is fixed, this function will continue to work.
==Chris