|
| 02 Aug 2013 12:07 PM |
Say I have a table like this:
example = {1,3,5,6}
--then I genereate a random number from 1 to 10.
num = math.random(1,10)
--Would it be possible to check if that number is in the table without using for, like this:
for i = 1,4 do if example[i] == num then --bleh end end
--And I don't want this either :
if example[1] == num or example[2] == num ,etc |
|
|
| Report Abuse |
|
iIikeyou
|
  |
| Joined: 07 Mar 2012 |
| Total Posts: 1659 |
|
|
| 02 Aug 2013 12:10 PM |
local start={1,3,5,6} local finish={} for _,v in pairs(start)do finish[v]=true end
local num=math.random(1,10) if finish[num]then --bleh end
|
|
|
| Report Abuse |
|