isInList
Revision as of 18:55, 15 December 2011 by Mitzpatrick Fitzsimmons (talk | contribs) (Created page with "{{LSL_Function |mode=user |func=IsInList |p1_type=list|p1_name=data |p2_type=string|p2_name=name |return_type=integer |return_text= |func_desc='''This function can be used to det…")
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Summary
Function: integer IsInList( list data, string name );
This function can be used to determine if a string variable is in a list
Returns an integer
• list | data | |||
• string | name |
![]() |
Tip: other variable types can be used with the exception of lists |
<lsl> integer IsInList(list data, string name) {
integer i; for(i=0; i < llGetListLength(data);i++) { if(llList2String(data, i) == name) { return TRUE; } } return FALSE;
}
</lsl>
![]() |
Tip: See my wiki page for a video tutorial of this function |
<lsl> // Simple Visitor's List that will not allow duplicate list entries using the IsInList() function default {
state_entry() { llListen(-23467589, "", "", ""); llSensorRepeat("", "", AGENT, 10.0, PI, 180); llSetTimerEvent(86400); } touch_start(integer total_number) { llTextBox(llDetectedKey(0), "What are you looking for?", -23467589); TypeOutList(); } listen(integer channel, string name, key id, string message) { if(IsInList(visitors, message)) { llSay(0, message + " is in the list."); }else{ llSay(0, message + " is not in the list"); } } sensor(integer detected) { integer i; for(i=0; i < detected; i++) { if(IsInList(visitors, llDetectedName(i))) { // DO NOTHING- already in the list }else{ visitors += llDetectedName(0); llOwnerSay("Added " + llDetectedName(0) + " to the visitors list. \nFree Memory: " + (string) llGetFreeMemory()); llOwnerSay("There are now " + (string) llGetListLength(visitors) + " names in the visitors list."); } } } timer() { // Optional llEmail("your_email_address@your_domain.com", "Here is the Visitors List for today", llList2CSV(visitors) ); }
} </lsl>