-- set machine level to whatever in program input
local names = {"Normal", "Bronze", "Silver", "Gold", "Sapphire", "Emerald", "Ruby", "Amethyst", "Diamond", "Opal", "Crystal", "Topaz", "Painite", "Azure", "Quartz", "Ammolite", "Flourite", "Citrine", "Tourmaline", "Bismuth", "Obsidian", "Chromite"}
function round100(n)
return math.floor(n*100)/100
end
function round3(n)
return math.floor(n/3)*3
end
local signs = {
"K",
"M",
"B",
"T",
"Qd",
"Qn",
"Sx",
"Sp",
"Oc",
"No",
"De",
"UDe",
}
function shorten(n)
if n >= 1000 then
local num = round100(n/10^round100(round3(math.floor(math.log10(n)))))
local sign = signs[round3(math.floor(math.log10(n)))/3]
return num..sign
else
return n
end
end
function getChance(increment, amount)
local chanceTable = {}
for i = 1, amount do
chanceTable[i] = increment^(i-1)
end
return chanceTable
end
function getRNG(maxAmount, num, luck)
return maxAmount/(maxAmount/(num/luck))
end
local luck = 1
local num = io.read()
for i = 1, (num-1) do
luck = luck + math.sqrt(luck)
end
local boost = 1
luck = luck * boost
for i, v in pairs(names) do
local chances = getChance(10, #names)
local chance = chances[i]
local rng = getRNG(chances[#chances], chance, luck)
print(v.." RNG: 1/"..shorten(round100(rng)).." Chance: 1/"..shorten(chance))
end
To embed this project on your website, copy the following code and paste it into your website's HTML: