Difference between revisions of "LlListFindList"
Jump to navigation
Jump to search
Core Taurog (talk | contribs) |
(<lsl> example) |
||
Line 11: | Line 11: | ||
|caveats=*Strict type matching is enforced. | |caveats=*Strict type matching is enforced. | ||
|constants | |constants | ||
|examples= | |examples=<lsl>list numbers = [1, 2, 3, 4, 5]; | ||
< | |||
list numbers = [1, 2, 3, 4, 5]; | |||
default | default | ||
{ | { | ||
Line 26: | Line 24: | ||
} | } | ||
} | } | ||
} | }</lsl> | ||
</ | |||
|helpers= | |helpers= | ||
An easy way to see if an item exists in a list... | An easy way to see if an item exists in a list... | ||
< | <lsl>if(~llListFindList(myList, (list)item)) | ||
if(~llListFindList(myList, (list)item)) | |||
{//it exists | {//it exists | ||
//This works because ~(-1) == 0 | //This works because ~(-1) == 0 | ||
//It saves bytecode and is faster then doing != -1 | //It saves bytecode and is faster then doing != -1 | ||
} | }</lsl> | ||
</ | |||
|also_functions= | |also_functions= | ||
{{LSL DefineRow||[[llSubStringIndex]]|Find a string in another string}} | {{LSL DefineRow||[[llSubStringIndex]]|Find a string in another string}} |
Revision as of 10:26, 27 February 2008
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Summary
Function: integer llListFindList( list src, list test );201 | Function ID |
0.0 | Forced Delay |
10.0 | Energy |
Returns an integer that is the index of the first instance of test in src.
• list | src | |||
• list | test |
If test is not found in src, -1 is returned.
The index of the first entry in the list is 0
Caveats
Examples
<lsl>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 } }}</lsl>
Useful Snippets
An easy way to see if an item exists in a list... <lsl>if(~llListFindList(myList, (list)item)) {//it exists
//This works because ~(-1) == 0 //It saves bytecode and is faster then doing != -1
}</lsl>
See Also
Functions
• | llSubStringIndex | – | Find a string in another string |