Anonymous

Module:Monsters: Difference between revisions

From Melvor Idle
Added handling for items that haven't been added yet
m (Remove link if SlayerTier is N/A)
(Added handling for items that haven't been added yet)
Line 647: Line 647:
     for i, row in Shared.skpairs(monster.lootTable) do
     for i, row in Shared.skpairs(monster.lootTable) do
       local thisItem = Items.getItemByID(row[1])
       local thisItem = Items.getItemByID(row[1])
     
       local maxQty = row[3]
       local maxQty = row[3]
       result = result..'\r\n|-\r\n|'..Icons.Icon({thisItem.name, type='item'})
       if thisItem ~= nil then
    result = result..'\r\n|-\r\n|'..Icons.Icon({thisItem.name, type='item'})
  else
      result = result..'\r\n|-\r\n|Unknown Item[[Category:Pages with script errors]]'
    end
       result = result..'||style="text-align:right" data-sort-value="'..maxQty..'"|'
       result = result..'||style="text-align:right" data-sort-value="'..maxQty..'"|'


Line 657: Line 662:


       --Adding price columns
       --Adding price columns
      local itemPrice = thisItem.sellsFor ~= nil and thisItem.sellsFor or 0
  local itemPrice = 0
       if itemPrice == 0 or maxQty == 1 then
       if thisItem == nil then
        result = result..'||'..Icons.GP(itemPrice)
      result = result..'||data-sort-value="0"|???'
       else
       else
        result = result..'||'..Icons.GP(itemPrice, itemPrice * maxQty)
        itemPrice = thisItem.sellsFor ~= nil and thisItem.sellsFor or 0
      if itemPrice == 0 or maxQty == 1 then
        result = result..'||'..Icons.GP(itemPrice)
      else
        result = result..'||'..Icons.GP(itemPrice, itemPrice * maxQty)
      end
       end
       end