Anonymous

Module:Skills/Artisan: Difference between revisions

From Melvor Idle
getFletchingTable
m (Fix getRunecraftingTable error description)
(getFletchingTable)
Line 187: Line 187:
     result = result..'\r\n| style="text-align:right"|'..string.format("%.2f", xps)
     result = result..'\r\n| style="text-align:right"|'..string.format("%.2f", xps)
     result = result..'\r\n| style="text-align:right"|'..string.format("%.2f", gps)
     result = result..'\r\n| style="text-align:right"|'..string.format("%.2f", gps)
  end
  result = result..'\r\n|}'
  return result
end
function p.getFletchingTable(frame)
  local category = frame.args ~= nil and frame.args[1] or frame
  local data = nil
  if    category == "Arrows"    then data = SkillData.Fletching.Arrows
  elseif category == "Shortbows" then data = SkillData.Fletching.Shortbows
  elseif category == "Longbows"  then data = SkillData.Fletching.Longbows
  elseif category == "Bolts"    then data = SkillData.Fletching.Bolts
  elseif category == "Crossbows" then data = SkillData.Fletching.Crossbows
  elseif category == "Javelins"  then data = SkillData.Fletching.Javelins
  end
  if data == nil then
    return "ERROR: Invalid Fletching category name.[[Category:Pages with script errors]]"
  end
  local result = '{| class="wikitable sortable stickyHeader"'
  result = result..'\r\n|- class="headerRow-0"'
  result = result..'\r\n!Item\r\n!Name\r\n!Fletching Level\r\n!Experience'
  result = result..'\r\n!Quantity\r\n!Sells For\r\n!Ingredients'
  local fletchArray = {}
  for i, fc in Shared.skpairs(data) do
    table.insert(fletchArray, fc)
  end
  table.sort(fletchArray, function(a, b) return a.fletchingLevel < b.fletchingLevel end)
  for i, fletch in Shared.skpairs(fletchArray) do
    result = result..'\r\n|-'
    result = result..'\r\n| style="text-align: left;" | '..Icons.Icon({fletch.name, type='item', size='50', notext=true})
    result = result..'\r\n| style ="text-align: left;" |[['..fletch.name..']]'
    result = result..'\r\n| style="text-align:right"|'..fletch.fletchingLevel
    result = result..'\r\n| style="text-align:right"|'..fletch.fletchingXP
    result = result..'\r\n| style="text-align:right"|'..fletch.fletchQty
    result = result..'\r\n| style="text-align:right"|'..fletch.sellsFor
    local matArray = {}
    for j, mat in Shared.skpairs(fletch.fletchReq) do
      local matItem = Items.getItemByID(mat.id)
      table.insert(matArray, Icons.Icon({matItem.name, type='item', notext=true, qty=mat.qty}))
    end
    result = result..'\r\n|'..table.concat(matArray, ' ')
   end
   end


285

edits