Is there a way to generate something randomly with one outcome being more probable than the other? For example, could I have one map having an 80% chance of happening, another map having a 19% chance of loading, and another one having a 1% chance of loading?
local chances = { ['variable1'] = 70, ['variable2'] = 20, ['variable3'] = 10, -- [variable] = chance integer } local results = {} table.foreach(chances, function(key, value) for i = 1, value do table.insert(results, key) print(key) end end) local random = math.random(#results) print(random) print(results[random])