Lua does not have strict arrays like other languages ββ- it only has hash tables. Tables in Lua are considered massive when their indexes are numerically and densely packed without leaving spaces. The indices in the following table will be 1, 2, 3, 4 .
local t = {'a', 'b', 'c', 'd'}
When you have an array similar to a table, you can check to see if it contains a specific value by going through the table. You can use the for..in and ipairs to create a generic function.
local function has_value (tab, val) for index, value in ipairs(tab) do if value == val then return true end end return false end
We can use the if condition above to get our result.
if has_value(arr, 'b') then print 'Yep' else print 'Nope' end
To repeat my comment above, your current sample code is not a table of numbers like an array. Instead, it is a massive table containing table tables that have numbers in each of their first indexes. You will need to change the function above to work with your displayed code, making it less general.
local function has_value (tab, val) for index, value in ipairs(tab) do -- We grab the first index of our sub-table instead if value[1] == val then return true end end return false end
Lua is not a very large or complex language, and its syntax is very clear. If the above concepts are completely alien to you, you need to spend some time reading real literature, and not just copying examples. I would advise reading Lua Programming to make sure you understand the basics. This is the first edition intended for Lua 5.1.