if not name in Namez do
table.insert(Namez,name)
end
What would be the correct way to check if a name is not in the table?
if not name in Namez do
table.insert(Namez,name)
end
What would be the correct way to check if a name is not in the table?
Nothing is ready, you can create a function that does this, like this:
local function contains(tabela, valor)
for i = 1, #tabela do
if tabela[i] == valor then
return true
end
end
return false
end
local names = {"joão", "maria", "josé"}
if not contains(names, "carlos") then
table.insert(names, "carlos")
end
for i = 1, #names do
print(names[i])
end
See running on ideone . And no Coding Ground . Also I placed GitHub for future reference .