lua get index of table value code example
Example 1: how to access an index of a table lua
--How to access something in a table by its index in lua:
local mytable = {"Hi", 6,"Bye"}
--To access it:
mytable[1]
--or
mytable[2]
--or
mytable[3]
Example 2: Lua how to get the index of a nested table
function findTL(tbl)
for key, data in pairs(tbl) do
if data.tl == tlSearch then
return key
end
end
end
local key = findTL(objects, 22)