Anonymous

Module:Skills/Artisan: Difference between revisions

From Melvor Idle
Make getRunecraftingTable generic
(getRunecraftingComboRunes)
(Make getRunecraftingTable generic)
Line 140: Line 140:
end
end


function p.getRunecraftingRunes(frame)
function p.getRunecraftingTable(frame)
   local result = '{| class="wikitable sortable stickyHeader"'
   local category = frame.args ~= nil and frame.args[1] or frame
   result = result..'\r\n|- class="headerRow-0"'
  local data = nil
   result = result..'\r\n!Item\r\n!Name\r\n!Runecrafting Level\r\n!Experience'
  if    category == "Runes"     then data = SkillData.Runecrafting.Runes
   result = result..'\r\n!Item Price\r\n!Ingredients\r\n!XP/s\r\n!GP/s'
   elseif category == "ComboRunes" then data = SkillData.Runecrafting.ComboRunes
 
  elseif category == "Weapons"   then data = SkillData.Runecrafting.Weapons
   local rcArray = {}
   elseif category == "AirGear"    then data = SkillData.Runecrafting.AirGear
   for i, rc in Shared.skpairs(SkillData.Runecrafting.Runes) do
  elseif category == "WaterGear"  then data = SkillData.Runecrafting.WaterGear
    table.insert(rcArray, rc)
   elseif category == "EarthGear"  then data = SkillData.Runecrafting.EarthGear
   elseif category == "FireGear"   then data = SkillData.Runecrafting.FireGear
   end
   end
  table.sort(rcArray, function(a, b) return a.runecraftingLevel < b.runecraftingLevel end)
  for i, rune in Shared.skpairs(rcArray) do
    result = result..'\r\n|-'
    result = result..'\r\n| style="text-align: left;" | '..Icons.Icon({rune.name, type='item', size='50', notext=true})
    result = result..'\r\n| style ="text-align: left;" |[['..rune.name..']]'
    result = result..'\r\n| style="text-align:right"|'..rune.runecraftingLevel
    result = result..'\r\n| style="text-align:right"|'..rune.runecraftingXP
    result = result..'\r\n| style="text-align:right"|'..rune.sellsFor
    local matArray = {}
    for j, mat in Shared.skpairs(rune.runecraftReq) 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, ' ')


    local rcCraftTime = 2.00
  if data == nil then
    local xps = rune.runecraftingXP / rcCraftTime
     return "ERROR: Invalid area name.[[Category:Pages with script errors]]"
    local gps = rune.sellsFor / rcCraftTime
     result = result..'\r\n| style="text-align:right"|'..string.format("%.2f", xps)
    result = result..'\r\n| style="text-align:right"|'..string.format("%.2f", gps)
   end
   end


  result = result..'\r\n|}'
  return result
end
function p.getRunecraftingComboRunes(frame)
   local result = '{| class="wikitable sortable stickyHeader"'
   local result = '{| class="wikitable sortable stickyHeader"'
   result = result..'\r\n|- class="headerRow-0"'
   result = result..'\r\n|- class="headerRow-0"'
Line 185: Line 162:


   local rcArray = {}
   local rcArray = {}
   for i, rc in Shared.skpairs(SkillData.Runecrafting.ComboRunes) do
   for i, rc in Shared.skpairs(data) do
     table.insert(rcArray, rc)
     table.insert(rcArray, rc)
   end
   end
285

edits