Module:Monsters: Difference between revisions

Added sortvalues to loot chance & qty columns to ensure they sort properly
(Right-aligning fractions)
(Added sortvalues to loot chance & qty columns to ensure they sort properly)
Line 403: Line 403:
     for i, row in pairs(monster.lootTable) do
     for i, row in pairs(monster.lootTable) do
       local thisItem = Items.getItemByID(row[1])
       local thisItem = Items.getItemByID(row[1])
       result = result..'\r\n|-\r\n|'..Icons.Icon({thisItem.name, type='item'})..'||'
       result = result..'\r\n|-\r\n|'..Icons.Icon({thisItem.name, type='item'})
       if row[3] > 1 then result = result.. '1 - ' end
      result = result..'||style="text-align:right" data-sort-value="'..row[3]..'"|'
       result = result..row[3]
 
       if row[3] > 1 then  
        result = result.. '1 - '  
      end
       result = result..Shared.formatnum(row[3])


       local dropChance = (row[2] / totalWt * lootChance)
       local dropChance = (row[2] / totalWt * lootChance)
       result = result..'||style="text-align:right"|'..Shared.fraction(row[2] * lootChance, totalWt * 100)
       result = result..'||style="text-align:right" data-sort-value="'..row[2]..'"'
      result = result..'|'..Shared.fraction(row[2] * lootChance, totalWt * 100)
       result = result..'||style="text-align:right"|'..Shared.round(dropChance, 2, 2)..'%'
       result = result..'||style="text-align:right"|'..Shared.round(dropChance, 2, 2)..'%'
     end
     end