Module:Monsters: Difference between revisions

Fixed chest drop table quantity sorting issue.
(Added a Bosses category)
(Fixed chest drop table quantity sorting issue.)
Line 490: Line 490:


     --Sort the loot table by weight in descending order
     --Sort the loot table by weight in descending order
    for i, row in pairs(chest.dropTable) do
      if chest.dropQty ~= nil then
        table.insert(row, chest.dropQty[i])
      else
        table.insert(row, 1)
      end
    end
     table.sort(chest.dropTable, function(a, b) return a[2] > b[2] end)
     table.sort(chest.dropTable, function(a, b) return a[2] > b[2] end)
     for i, row in pairs(chest.dropTable) do
     for i, row in pairs(chest.dropTable) do
       local thisItem = Items.getItemByID(row[1])
       local thisItem = Items.getItemByID(row[1])
       local qty = 1
       local qty = row[3]
      if chest.dropQty ~= nil then qty = chest.dropQty[i] end
       result = result..'\r\n|-\r\n|'..Icons.Icon({thisItem.name, type='item'})
       result = result..'\r\n|-\r\n|'..Icons.Icon({thisItem.name, type='item'})
       result = result..'||style="text-align:right" data-sort-value="'..qty..'"|'
       result = result..'||style="text-align:right" data-sort-value="'..qty..'"|'