Posted 21 September 2015 - 02:45 PM
I'm working on a game, and I have it to mine something, that it works out your mining level, and what your mining, and will do math.random() to pick a number, between 1, and what it's worked out. I want to be-able to have it work out the percentage change of succesfully mining it
This just shows me the chance I have to mine it, with a mining level of 41, and the miningRequiredLevel at 30, chance = 21.95122, but I would like to know how to make that appear as a percentage, for another thing you can mine at level 1, with a mining level of 41 it's chance is 1, so that it's prints as "1/1" meaning a 100% success rate, I just don't understand percentages enough to be-able to make something appear as one, I did try Google it, but couldn't work it out, so any help would be much appreciated
chance = miningRequiredLevel/miningLevel*30
randomNum = math.random(1,chance)
cPrint(randomNum.."/"..chance)
This just shows me the chance I have to mine it, with a mining level of 41, and the miningRequiredLevel at 30, chance = 21.95122, but I would like to know how to make that appear as a percentage, for another thing you can mine at level 1, with a mining level of 41 it's chance is 1, so that it's prints as "1/1" meaning a 100% success rate, I just don't understand percentages enough to be-able to make something appear as one, I did try Google it, but couldn't work it out, so any help would be much appreciated