|
| 11 Jun 2017 08:20 PM |
Hey. How would I make a table with a percentage and randomize it?
tables = { ["Outcome1"] = 5% ["Outcome2"] = 95% }
local random = tables[math.random(1,#tables)]
and have Outcome2 have a 95% chance of being chosen while Outcome1 has a 5% chance? |
|
|
| Report Abuse |
|
|
| 11 Jun 2017 10:17 PM |
What's the purpose of the values in those tables?
You can get a random variable with math.random and then use an if statement to control the outcome.
random = math.random()
if random < .05 then --Outcome 1 else --Outcome 2 end
The math.random() values give values between 0, and 1 exclusive [0,1) so you can do math if you want to give values between 0 and 100 [0, 100) for convenience --math.random()*100 |
|
|
| Report Abuse |
|