I want to generate 10 number out of a table but a number may only be selected one’s.
Tried this
function randomNumber()
z={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20}
z2={}
for i=1,10 do
z2[i]=math.random(1,#z)
for k,v in pairs(z2) do
if z2[i]==v then break end
end
end
table.insert(z2,z2[i])
for k,v in pairs(z2) do print(k,v) end
end
function setup()
print(table.concat(rand()," "))
end
function rand()
local tab={}
while #tab<10 do
local r=math.random(20)
local found=false
for z=1,#tab do
if tab[z]==r then
found=true
end
end
if not found then
table.insert(tab,r)
end
end
return(tab)
end