Module:Skills/Gathering: Difference between revisions

getSpecialFishingTable: Show smaller chance values to 2sf
(getMiningOresTable: Further fixes for v1.0.2 data)
(getSpecialFishingTable: Show smaller chance values to 2sf)
Line 205: Line 205:


local dropChance = (row[2] / totalWt) * 100
local dropChance = (row[2] / totalWt) * 100
-- If chance is less than 01.0% then show 2 significant figures, otherwise 2 decimal places
local fmt = (dropChance < 0.10 and '%.2g') or '%.2f'
result = result..'||style="text-align:right" data-sort-value="'..row[2]..'"'
result = result..'||style="text-align:right" data-sort-value="'..row[2]..'"'
result = result..'|'..Shared.fraction(row[2], totalWt)
result = result..'|'..Shared.fraction(row[2], totalWt)
result = result..'||style="text-align:right"|'..Shared.round(dropChance, 2, 2)..'%'
result = result..'||style="text-align:right"|'..string.format(fmt, dropChance)..'%'
lootValue = lootValue + (dropChance * 0.01 * thisItem.sellsFor)
lootValue = lootValue + (dropChance * 0.01 * thisItem.sellsFor)
end
end