Anonymous

Module:Items/SourceTables: Difference between revisions

From Melvor Idle
_getItemLootSourceTable: Amend display of very small chances
(Resolve issue with dungeon sources when dungeons had more than one reward. Also fix indentation oddities)
(_getItemLootSourceTable: Amend display of very small chances)
Line 620: Line 620:
table.insert(rowPart, '\r\n|style="text-align: right;" data-sort-value="'..qty..'"|'..minqty)
table.insert(rowPart, '\r\n|style="text-align: right;" data-sort-value="'..qty..'"|'..minqty)
if qty ~= minqty then table.insert(rowPart, ' - '..qty) end
if qty ~= minqty then table.insert(rowPart, ' - '..qty) end
local chance = Shared.round(weight / totalWeight * 100, 2, 2)
local chance = weight / totalWeight * 100
-- If chance is less than 0.10% then show 2 significant figures, otherwise 2 decimal places
local fmt = (chance < 0.10 and '%.2g') or '%.2f'
chance = string.format(fmt, chance)
if weight >= totalWeight then
if weight >= totalWeight then
-- Fraction would be 1/1, so only show the percentage
-- Fraction would be 1/1, so only show the percentage