Advertisement
Bolodefchoco_LUAXML

[Table] table.find

Oct 24th, 2015
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.61 KB | None | 0 0
  1. --Creator: Bolodefchoco
  2. --Made in: 24/10/2015
  3. --Last update: 26/02/2017
  4. --[[ Notes:
  5.     Does:
  6.         Verifica se um valor se encontra na tabela table (Não utiliza ipairs, poderá chegar dentro das tabelas).
  7.     Args:
  8.         list --> Tabela a ser inserida
  9.         value --> Valor a ser procurado
  10.         index --> Caso seja necessário identificar o valor dentro de uma multiarray, informe o índice.
  11. ]]--
  12.  
  13. table.find = function(list,value,index)
  14.     for k,v in next,list do
  15.         if index then
  16.             if v[index] == value then
  17.                 return true,k
  18.             end
  19.         else
  20.             if v == value then
  21.                 return true,k
  22.             end
  23.         end
  24.     end
  25.     return false
  26. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement