Module:Skills/Artisan: Difference between revisions

Update for v1.0.2
m (Amend indentation)
(Update for v1.0.2)
Line 12: Line 12:
local category = frame.args ~= nil and frame.args[1] or frame
local category = frame.args ~= nil and frame.args[1] or frame
local itemArray = nil
local itemArray = nil
 
if category == "Cooking Fire" then  
if category == "Cooking Fire" then
itemArray = Items.getItems(function(item) return item.cookingCategory == 0 end)
itemArray = Items.getItems(function(item) return item.cookingCategory == 0 end)
elseif category == "Furnace" then  
elseif category == "Furnace" then
itemArray = Items.getItems(function(item) return item.cookingCategory == 1 and item.name ~= 'Lemon Cake' end)
itemArray = Items.getItems(function(item) return item.cookingCategory == 1 and item.name ~= 'Lemon Cake' end)
elseif category == "Pot" then  
elseif category == "Pot" then
itemArray = Items.getItems(function(item) return item.cookingCategory == 2 end)
itemArray = Items.getItems(function(item) return item.cookingCategory == 2 end)
else
else
Line 23: Line 23:
end
end
table.sort(itemArray, function(a, b) return a.cookingLevel < b.cookingLevel end)
table.sort(itemArray, function(a, b) return a.cookingLevel < b.cookingLevel end)
 
-- Logic for generating some cells of the table which are consistent for normal & perfect items
-- Logic for generating some cells of the table which are consistent for normal & perfect items
local getHealingCell = function(item, qty)
local getHealingCell = function(item, qty)
Line 39: Line 39:
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"'
Line 46: Line 46:
result = result..'\r\n|- class="headerRow-1"'
result = result..'\r\n|- class="headerRow-1"'
result = result..'\r\n!Normal!!' .. Icons.Icon({'Perfect', type='bonus', ext='png', notext=true, nolink=true}) .. '!!Normal!!' .. Icons.Icon({'Perfect', type='bonus', ext='png', notext=true, nolink=true})
result = result..'\r\n!Normal!!' .. Icons.Icon({'Perfect', type='bonus', ext='png', notext=true, nolink=true}) .. '!!Normal!!' .. Icons.Icon({'Perfect', type='bonus', ext='png', notext=true, nolink=true})
 
for i, item in Shared.skpairs(itemArray) do
for i, item in Shared.skpairs(itemArray) do
local perfectItem = nil
local perfectItem = nil
Line 97: Line 97:


local potionArray = {}
local potionArray = {}
for i, potion in Shared.skpairs(SkillData.Herblore.ItemData) do
for i, potion in Shared.skpairs(SkillData.Herblore.Potions) do
if potion.category == category then
if potion.category == category then
table.insert(potionArray, potion)
table.insert(potionArray, potion)
Line 110: Line 110:
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 ipairs(potionArray) do
local tierPots = {}
for j = 1, 4, 1 do
table.insert(tierPots, Items.getItemByID(potion.itemID[j]))
end
result = result..'\r\n|-'
result = result..'\r\n|-'
if potion.name == 'Bird Nests Potion' then
if potion.name == 'Bird Nests Potion' then
Line 122: Line 118:
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.baseXP


local matArray = {}
local matArray = {}
for j, mat in Shared.skpairs(tierPots[1].herbloreReq) do
for j, mat in ipairs(potion.itemCosts) 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, potionID in ipairs(potion.potionIDs) do
local tierPot = Items.getItemByID(potionID)
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})
Line 155: Line 152:
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
Line 180: Line 177:
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)


Line 213: Line 210:
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
Line 236: Line 233:
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)


Line 264: Line 261:
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.validSlots ~= nil and Shared.contains(item.validSlots, 'Ring')) and item.craftingLevel ~= nil end)
Items.getItems(function(item) return (item.validSlots ~= nil and Shared.contains(item.validSlots, 'Ring')) and item.craftingLevel ~= nil end)
elseif category == "Necklaces"  then data =  
elseif category == "Necklaces"  then data =
Items.getItems(function(item) return (item.validSlots ~= nil and Shared.contains(item.validSlots, 'Amulet')) and item.craftingLevel ~= nil end)
Items.getItems(function(item) return (item.validSlots ~= nil and Shared.contains(item.validSlots, 'Amulet')) and item.craftingLevel ~= nil end)
elseif category == "Bags" then data =
elseif category == "Bags" then data =
Line 280: Line 277:
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)