Anonymous

Module:Skills/Artisan: Difference between revisions

From Melvor Idle
Fixed indenting
No edit summary
(Fixed indenting)
Line 72: Line 72:
result = result..'||'..getHealingCell(item, qty)..'||'..getHealingCell(perfectItem, qty)
result = result..'||'..getHealingCell(item, qty)..'||'..getHealingCell(perfectItem, qty)
result = result..'||'..getSaleValueCell(item, qty)..'||'..getSaleValueCell(perfectItem, qty)
result = result..'||'..getSaleValueCell(item, qty)..'||'..getSaleValueCell(perfectItem, qty)
    local matArray = {}
local matArray = {}
    for j, reqSet in pairs(item.recipeRequirements)  do
for j, reqSet in pairs(item.recipeRequirements)  do
    for k, mat in pairs(reqSet) do
for k, mat in pairs(reqSet) do
local matItem = Items.getItemByID(mat.id)
local matItem = Items.getItemByID(mat.id)
table.insert(matArray, Icons.Icon({matItem.name, type='item', notext=true, qty=mat.qty}))
table.insert(matArray, Icons.Icon({matItem.name, type='item', notext=true, qty=mat.qty}))
    end
end
end
end
    result = result..'\r\n|'..table.concat(matArray, ' ')
result = result..'\r\n|'..table.concat(matArray, ' ')
end
end


Line 88: Line 88:
local tierSuffix = { 'I', 'II', 'III', 'IV' }
local tierSuffix = { 'I', 'II', 'III', 'IV' }
function p._getHerblorePotionTable(category)
function p._getHerblorePotionTable(category)
  if string.upper(category) == 'COMBAT' then
if string.upper(category) == 'COMBAT' then
    category = 0
category = 0
  elseif string.upper(category) == 'SKILL' then
elseif string.upper(category) == 'SKILL' then
    category = 1
category = 1
  elseif type(category) == 'string' then
elseif type(category) == 'string' then
    category = tonumber(category)
category = tonumber(category)
  end
end


  local potionArray = {}
local potionArray = {}
  for i, potion in Shared.skpairs(SkillData.Herblore.ItemData) do
for i, potion in Shared.skpairs(SkillData.Herblore.ItemData) do
    if potion.category == category then
if potion.category == category then
      table.insert(potionArray, potion)
table.insert(potionArray, potion)
    end
end
  end
end


  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"'
  result = result..'\r\n!Potion!!'..Icons.Icon({'Herblore', type='skill', notext=true})..' Level'
result = result..'\r\n!Potion!!'..Icons.Icon({'Herblore', type='skill', notext=true})..' Level'
  result = result..'!!XP!!Ingredients!!colspan="2"|Tier!!Value!!Charges!!Effect'
result = result..'!!XP!!Ingredients!!colspan="2"|Tier!!Value!!Charges!!Effect'


  table.sort(potionArray, function(a, b) return a.level < b.level end)
table.sort(potionArray, function(a, b) return a.level < b.level end)


  for i, potion in Shared.skpairs(potionArray) do
for i, potion in Shared.skpairs(potionArray) do
    local tierPots = {}
local tierPots = {}
    for j = 1, 4, 1 do
for j = 1, 4, 1 do
      table.insert(tierPots, Items.getItemByID(potion.itemID[j]))
table.insert(tierPots, Items.getItemByID(potion.itemID[j]))
    end
end
    result = result..'\r\n|-'
result = result..'\r\n|-'
    if potion.name == 'Bird Nests Potion' then
if potion.name == 'Bird Nests Potion' then
      result = result..'\r\n|rowspan="4"|[[Bird Nest Potion]]'
result = result..'\r\n|rowspan="4"|[[Bird Nest Potion]]'
    else
else
      result = result..'\r\n|rowspan="4"|[['..potion.name..']]'
result = result..'\r\n|rowspan="4"|[['..potion.name..']]'
    end
end
    result = result..'||rowspan="4" style="text-align:right"|'..potion.level
result = result..'||rowspan="4" style="text-align:right"|'..potion.level
    result = result..'||rowspan="4" style="text-align:right"|'..potion.herbloreXP
result = result..'||rowspan="4" style="text-align:right"|'..potion.herbloreXP


    local matArray = {}
local matArray = {}
    for j, mat in Shared.skpairs(tierPots[1].herbloreReq) do
for j, mat in Shared.skpairs(tierPots[1].herbloreReq) do
      local matItem = Items.getItemByID(mat.id)
local matItem = Items.getItemByID(mat.id)
      table.insert(matArray, Icons.Icon({matItem.name, type='item', notext=true, qty=mat.qty}))
table.insert(matArray, Icons.Icon({matItem.name, type='item', notext=true, qty=mat.qty}))
    end
end
    result = result..'||rowspan="4"|'..table.concat(matArray, ', ')..'||'
result = result..'||rowspan="4"|'..table.concat(matArray, ', ')..'||'
   
    local tierRows = {}
local tierRows = {}
    for j, tierPot in Shared.skpairs(tierPots) do
for j, tierPot in Shared.skpairs(tierPots) do
      local rowTxt = Icons.Icon({tierPot.name, type='item', notext=true})
local rowTxt = Icons.Icon({tierPot.name, type='item', notext=true})
      rowTxt = rowTxt..'||'..Icons.Icon({tierPot.name, tierSuffix[j], type = 'item', noicon = true})
rowTxt = rowTxt..'||'..Icons.Icon({tierPot.name, tierSuffix[j], type = 'item', noicon = true})
      rowTxt = rowTxt..'||style="text-align:right;" data-sort-value="'..tierPot.sellsFor..'"|'..Icons.GP(tierPot.sellsFor)
rowTxt = rowTxt..'||style="text-align:right;" data-sort-value="'..tierPot.sellsFor..'"|'..Icons.GP(tierPot.sellsFor)
      rowTxt = rowTxt..'||style="text-align:right;"|'..tierPot.potionCharges..'||'..tierPot.description
rowTxt = rowTxt..'||style="text-align:right;"|'..tierPot.potionCharges..'||'..tierPot.description
      table.insert(tierRows, rowTxt)
table.insert(tierRows, rowTxt)
    end
end
    result = result..table.concat(tierRows, '\r\n|-\r\n|')
result = result..table.concat(tierRows, '\r\n|-\r\n|')
  end
end


  result = result..'\r\n|}'
result = result..'\r\n|}'
  return result
return result
end
end


function p.getHerblorePotionTable(frame)
function p.getHerblorePotionTable(frame)
  local category = frame.args ~= nil and frame.args[1] or frame
local category = frame.args ~= nil and frame.args[1] or frame
  return p._getHerblorePotionTable(category)
return p._getHerblorePotionTable(category)
end
end


function p.getRunecraftingTable(frame)
function p.getRunecraftingTable(frame)
  local category = frame.args ~= nil and frame.args[1] or frame
local category = frame.args ~= nil and frame.args[1] or frame
  local data = nil
local data = nil


  if    category == "Runes"      then data =  
if    category == "Runes"      then data =  
        Items.getItems(function(item) return item.runecraftingCategory == 0 end)
Items.getItems(function(item) return item.runecraftingCategory == 0 end)
  elseif category == "ComboRunes" then data =  
elseif category == "ComboRunes" then data =  
        Items.getItems(function(item) return item.runecraftingCategory == 1 end)
Items.getItems(function(item) return item.runecraftingCategory == 1 end)
  elseif category == "Weapons"    then data =  
elseif category == "Weapons"    then data =  
        Items.getItems(function(item) return item.runecraftingCategory == 2 and item.runecraftingID end)
Items.getItems(function(item) return item.runecraftingCategory == 2 and item.runecraftingID end)
  elseif category == "AirGear"    then data =  
elseif category == "AirGear"    then data =  
        Items.getItems(function(item) return item.runecraftingCategory == 3 end)
Items.getItems(function(item) return item.runecraftingCategory == 3 end)
  elseif category == "WaterGear"  then data =  
elseif category == "WaterGear"  then data =  
        Items.getItems(function(item) return item.runecraftingCategory == 4 end)
Items.getItems(function(item) return item.runecraftingCategory == 4 end)
  elseif category == "EarthGear"  then data =  
elseif category == "EarthGear"  then data =  
        Items.getItems(function(item) return item.runecraftingCategory == 5 end)
Items.getItems(function(item) return item.runecraftingCategory == 5 end)
  elseif category == "FireGear"  then data =  
elseif category == "FireGear"  then data =  
        Items.getItems(function(item) return item.runecraftingCategory == 6 end)
Items.getItems(function(item) return item.runecraftingCategory == 6 end)
  end
end


  if data == nil then
if data == nil then
    return "ERROR: Invalid Runecrafting category name.[[Category:Pages with script errors]]"
return "ERROR: Invalid Runecrafting category name.[[Category:Pages with script errors]]"
  end
end


  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"'
  result = result..'\r\n!Item\r\n!Name\r\n!'..Icons.Icon({'Runecrafting', type='skill', notext=true})..' Level\r\n!Experience'
result = result..'\r\n!Item\r\n!Name\r\n!'..Icons.Icon({'Runecrafting', type='skill', notext=true})..' Level\r\n!Experience'
  result = result..'\r\n!Item Price\r\n!Ingredients\r\n!XP/s\r\n!GP/s'
result = result..'\r\n!Item Price\r\n!Ingredients\r\n!XP/s\r\n!GP/s'


  table.sort(data, function(a, b) return (a.runecraftingLevel == b.runecraftingLevel and a.id < b.id)  
table.sort(data, function(a, b) return (a.runecraftingLevel == b.runecraftingLevel and a.id < b.id)  
                                      or a.runecraftingLevel <  b.runecraftingLevel end)
or a.runecraftingLevel <  b.runecraftingLevel end)


  for i, rune in Shared.skpairs(data) do
for i, rune in Shared.skpairs(data) do
    result = result..'\r\n|-'
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;" | '..Icons.Icon({rune.name, type='item', size='50', notext=true})
    result = result..'\r\n| style ="text-align: left;" |'..Icons.Icon({rune.name, type='item', noicon=true})
result = result..'\r\n| style ="text-align: left;" |'..Icons.Icon({rune.name, type='item', noicon=true})
    result = result..'\r\n| style="text-align:right"|'..rune.runecraftingLevel
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.runecraftingXP
    result = result..'\r\n| style="text-align:right"|'..rune.sellsFor
result = result..'\r\n| style="text-align:right"|'..rune.sellsFor


    local matArray = {}
local matArray = {}
    for j, mat in Shared.skpairs(rune.runecraftReq) do
for j, mat in Shared.skpairs(rune.runecraftReq) do
      local matItem = Items.getItemByID(mat.id)
local matItem = Items.getItemByID(mat.id)
      table.insert(matArray, Icons.Icon({matItem.name, type='item', notext=true, qty=mat.qty}))
table.insert(matArray, Icons.Icon({matItem.name, type='item', notext=true, qty=mat.qty}))
    end
end
    result = result..'\r\n|'..table.concat(matArray, ' ')
result = result..'\r\n|'..table.concat(matArray, ' ')


    local rcCraftTime = 2.00
local rcCraftTime = 2.00
    local xps = rune.runecraftingXP / rcCraftTime
local xps = rune.runecraftingXP / rcCraftTime
    local gps = rune.sellsFor / rcCraftTime
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", 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
end


  result = result..'\r\n|}'
result = result..'\r\n|}'
  return result
return result
end
end


function p.getFletchingTable(frame)
function p.getFletchingTable(frame)
  local category = frame.args ~= nil and frame.args[1] or frame
local category = frame.args ~= nil and frame.args[1] or frame
  local data = nil
local data = nil


  if    category == "Arrows"    then  
if    category == "Arrows"    then  
  data = Items.getItems(function(item) return item.fletchingCategory == 0 end)
data = Items.getItems(function(item) return item.fletchingCategory == 0 end)
  elseif category == "Shortbows" then  
elseif category == "Shortbows" then  
  data = Items.getItems(function(item) return item.fletchingCategory == 1 end)
data = Items.getItems(function(item) return item.fletchingCategory == 1 end)
  elseif category == "Longbows"  then  
elseif category == "Longbows"  then  
  data = Items.getItems(function(item) return item.fletchingCategory == 2 end)
data = Items.getItems(function(item) return item.fletchingCategory == 2 end)
  elseif category == "Bolts"    then  
elseif category == "Bolts"    then  
  data =  Items.getItems(function(item) return item.fletchingCategory == 3 end)
data =  Items.getItems(function(item) return item.fletchingCategory == 3 end)
  elseif category == "Crossbows" then  
elseif category == "Crossbows" then  
  data = Items.getItems(function(item) return item.fletchingCategory == 4 end)
data = Items.getItems(function(item) return item.fletchingCategory == 4 end)
  elseif category == "Javelins"  then  
elseif category == "Javelins"  then  
  data = Items.getItems(function(item) return item.fletchingCategory == 5 end)
data = Items.getItems(function(item) return item.fletchingCategory == 5 end)
  end
end


  if data == nil then
if data == nil then
    return "ERROR: Invalid Fletching category name.[[Category:Pages with script errors]]"
return "ERROR: Invalid Fletching category name.[[Category:Pages with script errors]]"
  end
end


  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"'
  result = result..'\r\n!Item\r\n!Name\r\n!Fletching Level\r\n!Experience'
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'
result = result..'\r\n!Quantity\r\n!Sells For\r\n!Ingredients'


  table.sort(data, function(a, b) return (a.fletchingLevel == b.fletchingLevel and a.id < b.id)  
table.sort(data, function(a, b) return (a.fletchingLevel == b.fletchingLevel and a.id < b.id)  
                                      or a.fletchingLevel <  b.fletchingLevel end)
or a.fletchingLevel <  b.fletchingLevel end)


  for i, fletch in Shared.skpairs(data) do
for i, fletch in Shared.skpairs(data) do
    result = result..'\r\n|-'
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;" | '..Icons.Icon({fletch.name, type='item', size='50', notext=true})
    result = result..'\r\n| style ="text-align: left;" |'..Icons.Icon({fletch.name, type='item', noicon=true})
result = result..'\r\n| style ="text-align: left;" |'..Icons.Icon({fletch.name, type='item', noicon=true})
    result = result..'\r\n| style="text-align:right"|'..fletch.fletchingLevel
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.fletchingXP
    result = result..'\r\n| style="text-align:right"|'..fletch.fletchQty
result = result..'\r\n| style="text-align:right"|'..fletch.fletchQty
    result = result..'\r\n| style="text-align:right"|'..fletch.sellsFor
result = result..'\r\n| style="text-align:right"|'..fletch.sellsFor


    local matArray = {}
local matArray = {}
    for j, mat in Shared.skpairs(fletch.fletchReq) do
for j, mat in Shared.skpairs(fletch.fletchReq) do
      local matItem = Items.getItemByID(mat.id)
local matItem = Items.getItemByID(mat.id)
      table.insert(matArray, Icons.Icon({matItem.name, type='item', notext=true, qty=mat.qty}))
table.insert(matArray, Icons.Icon({matItem.name, type='item', notext=true, qty=mat.qty}))
    end
end
    result = result..'\r\n|'..table.concat(matArray, ' ')
result = result..'\r\n|'..table.concat(matArray, ' ')
  end
end


  result = result..'\r\n|}'
result = result..'\r\n|}'
  return result
return result
end
end


function p.getCraftingTable(frame)
function p.getCraftingTable(frame)
  local category = frame.args ~= nil and frame.args[1] or frame
local category = frame.args ~= nil and frame.args[1] or frame
  local data = nil
local data = nil


  if    category == "Leather"    then data =  
if    category == "Leather"    then data =  
        Items.getItems(function(item) return item.tier == "Leather" or item.tier == "Hard Leather" end)
Items.getItems(function(item) return item.tier == "Leather" or item.tier == "Hard Leather" end)
  elseif category == "Dragonhide" then data =  
elseif category == "Dragonhide" then data =  
        Items.getItems(function(item) return item.tier == "Dragonhide" and item.craftingLevel ~= nil end)
Items.getItems(function(item) return item.tier == "Dragonhide" and item.craftingLevel ~= nil end)
  elseif category == "Rings"      then data =  
elseif category == "Rings"      then data =  
        Items.getItems(function(item) return item.type == "Ring" and item.craftingLevel ~= nil end)
Items.getItems(function(item) return item.type == "Ring" and item.craftingLevel ~= nil end)
  elseif category == "Necklaces"  then data =  
elseif category == "Necklaces"  then data =  
        Items.getItems(function(item) return item.type == "Amulet" and item.craftingLevel ~= nil end)
Items.getItems(function(item) return item.type == "Amulet" and item.craftingLevel ~= nil end)
  elseif category == "Bags"   then data =
elseif category == "Bags" then data =
  Items.getItems(function(item) return item.type == 'Bag' and item.craftingLevel ~= nil end)
Items.getItems(function(item) return item.type == 'Bag' and item.craftingLevel ~= nil end)
  end
end


  if data == nil then
if data == nil then
    return "ERROR: Invalid Crafting category name.[[Category:Pages with script errors]]"
return "ERROR: Invalid Crafting category name.[[Category:Pages with script errors]]"
  end
end


  table.sort(data, function(a, b) return (a.craftingLevel == b.craftingLevel and a.id < b.id)  
table.sort(data, function(a, b) return (a.craftingLevel == b.craftingLevel and a.id < b.id)  
                                      or a.craftingLevel <  b.craftingLevel end)
or a.craftingLevel <  b.craftingLevel end)


  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"'
  result = result..'\r\n!Item\r\n!Name\r\n!'..Icons.Icon({'Crafting', type='skill', notext=true})..' Level\r\n!Experience'
result = result..'\r\n!Item\r\n!Name\r\n!'..Icons.Icon({'Crafting', type='skill', notext=true})..' Level\r\n!Experience'
  result = result..'\r\n!Item Price\r\n!Ingredients'
result = result..'\r\n!Item Price\r\n!Ingredients'


  for i, craft in Shared.skpairs(data) do
for i, craft in Shared.skpairs(data) do
    result = result..'\r\n|-'
result = result..'\r\n|-'
    result = result..'\r\n| style="text-align: left;" | '..Icons.Icon({craft.name, type='item', size='50', notext=true})
result = result..'\r\n| style="text-align: left;" | '..Icons.Icon({craft.name, type='item', size='50', notext=true})
    result = result..'\r\n| style ="text-align: left;" |'..Icons.Icon({craft.name, type='item', noicon=true})
result = result..'\r\n| style ="text-align: left;" |'..Icons.Icon({craft.name, type='item', noicon=true})
    result = result..'\r\n| style="text-align:right"|'..craft.craftingLevel
result = result..'\r\n| style="text-align:right"|'..craft.craftingLevel
    result = result..'\r\n| style="text-align:right"|'..craft.craftingXP
result = result..'\r\n| style="text-align:right"|'..craft.craftingXP
    result = result..'\r\n| style="text-align:right"|'..craft.sellsFor
result = result..'\r\n| style="text-align:right"|'..craft.sellsFor


    local matArray = {}
local matArray = {}
    if craft.craftGPCost ~= nil and craft.craftGPCost > 0 then
if craft.craftGPCost ~= nil and craft.craftGPCost > 0 then
    table.insert(matArray, Icons.GP(craft.craftGPCost))
table.insert(matArray, Icons.GP(craft.craftGPCost))
    end
end
    for j, mat in Shared.skpairs(craft.craftReq) do
for j, mat in Shared.skpairs(craft.craftReq) do
      local matItem = Items.getItemByID(mat.id)
local matItem = Items.getItemByID(mat.id)
      table.insert(matArray, Icons.Icon({matItem.name, type='item', notext=true, qty=mat.qty}))
table.insert(matArray, Icons.Icon({matItem.name, type='item', notext=true, qty=mat.qty}))
    end
end
    result = result..'\r\n|'..table.concat(matArray, ', ')
result = result..'\r\n|'..table.concat(matArray, ', ')
  end
end


  result = result..'\r\n|}'
result = result..'\r\n|}'
  return result
return result
end
end


return p
return p