User:Vegas Silverweb/vsListFindList

From Second Life Wiki
Jump to: navigation, search

Like ListFindList but tries for match based on implicit cast to string, so works pretty good for everything except vectors and rotations initialized in-place with integers.

<lsl> integer vsListFindList(list haystack,list needle) {

   integer i;
   integer j = llGetListLength(haystack);
   string s = llList2String(needle,0);
   for(i=0;i<j;i++) {
       if(llList2String(haystack,i)==s) return i;
       }
   return -1;
   }

</lsl>