Find if an item exists in an array
Posted: Sun Jan 17, 2010 11:51 pm
I'm having trouble finding an appropriate function for what I want to do. I'm used to using the existence of an item in an array to track things in other clients, and I was hoping that there was a function to do the same in Lua. I'm looking for something that will return 1 or true if a string exists inside a given array, and 0, false, or nil if it doesn't.
Example:
>> foo = {"one fish", "two fish", "red fish", "blue fish"}
>> function_I_want_to_use( foo, "one fish")
true
>> function_I_want_to_use( foo, "lorax")
false
something along those lines
Example:
>> foo = {"one fish", "two fish", "red fish", "blue fish"}
>> function_I_want_to_use( foo, "one fish")
true
>> function_I_want_to_use( foo, "lorax")
false
something along those lines