Lua how to check what index belongs to value