Module:Items/SourceTables: Difference between revisions

Fix for summoning material table's non-shard quantity and better formatting
(Adds crafting table for summoning)
(Fix for summoning material table's non-shard quantity and better formatting)
Line 163: Line 163:
     lvl = item.summoningLevel
     lvl = item.summoningLevel
     xp = item.summoningXP
     xp = item.summoningXP
     req = item.summoningReq
     local ShardCostArray = {}
    req = 'One of the following recipes:<br/>\r\n'
     for j, cost in Shared.skpairs(item.summoningReq[1]) do
     for recipeIndex, recipe in pairs(item.summoningReq) do
       if cost.id >= 0 then
       if recipeIndex > 1 then req = req..'<br/><br/>\r\n' end
        local item = Items.getItemByID(cost.id)
       for i, mat in pairs(recipe) do
        if item.type == 'Shard' then
         if i > 1 then req = req..'<br/>' end
          table.insert(ShardCostArray, Icons.Icon({item.name,  type='item', notext=true, qty=cost.qty}))
        local matItem = Items.getItemByID(mat.id)
        end
        if matItem == nil then
      end
          req = req..mat.qty..'x ?????'
    end
    req = table.concat(ShardCostArray, ', ')
    req = req..'<br/>\r\nand one of the following<br/>\r\n'
    local OtherCostArray = {}
    local recipeGPCost = SkillData.Summoning.Settings.recipeGPCost
    for j, altCost in Shared.skpairs(item.summoningReq) do
      local nonShardArray = {}
       for k, cost in Shared.skpairs(altCost) do
         if cost.id >= 0 then
          local item = Items.getItemByID(cost.id)
          if item.type ~= 'Shard' then
            local sellPrice = item.sellsFor
            if sellPrice < 20 then sellPrice = 20 end
            table.insert(nonShardArray, Icons.Icon({item.name, type='item', notext=true, qty=math.max(1, math.floor(recipeGPCost / sellPrice))}))
          end
         else
         else
           req = req..Icons.Icon({matItem.name, type='item', qty=mat.qty})
           if cost.id == -4 then
            table.insert(nonShardArray, Icons.GP(recipeGPCost))
          elseif cost.id == -5 then
            table.insert(nonShardArray, Icons.SC(recipeGPCost))
          end
         end
         end
       end
       end
      table.insert(OtherCostArray, table.concat(nonShardArray, ', '))
     end
     end
    req = req..table.concat(OtherCostArray, "<br/>'''OR''' ")
     qty = item.summoningQty
     qty = item.summoningQty
     time = 3
     time = 3