Hi,
The way to do it would be within a loop - and actually possible within original loop i think
by adding a test and a flag
if randNum01 == “2” then
flag2 = true
end
[lua]
LowhestN = 1
HighestN = 80
owMany = (HighestN - LowhestN) + 1
cntUp = 0
ran = {}
for i = 1, owMany do
ran[i] = LowhestN + cntUp
cntUp = i
print( i, “ran”, ran[1] )
end
for i = 1, 20 do
q01 = math.random(#ran)
randNum01 = ran[q01] – chose a number from the table (Position).
table.remove(ran, q01) --remove that number.
if randNum01 == “2” then
flag2 = true
end
end
[/lua]
I’m half asleep but this code works for printing out to the terminal - if you wanted to keep the 20 numbers selected then you would obviously need to store them & the best way for that would be another table.
my20Num = {}
and then adding
my20num[i] = randNum01
within the loop
also if you wanted to know which of the randoms = “2”
then create a numIs2 = {}
and add it into the loop with an if else statement.
I’m only a new programmer myself - and tend to go towards the simple and obvious rather than the complex and stylish code.
With your Keno i think you might want to store the 20 numbers - so you can use text objects to display, and since the numbers are random would need to know the location within the table of 20 that matchup to your players numbers hence the table of numIs2.
loops as always are your friend in this case.
Again just going by code logic here -( have not tried the additions )
T.
oh in my example the 2 is “2” as a text so try it with 2 as number as well