4,951
edits
Falterfire (talk | contribs) (adding a category real quick to check if a specific bit of code is actually in use anywhere) |
Falterfire (talk | contribs) (Swapping over to Auron's v0.21 test version) |
||
Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
local ItemData = mw.loadData('Module:Items/data') | local ItemData = mw.loadData('Module:Items/data') | ||
local Constants = require('Module:Constants') | local Constants = require('Module:Constants') | ||
local Shared = require('Module:Shared') | local Shared = require('Module:Shared') | ||
local Icons = require('Module:Icons') | local Icons = require('Module:Icons') | ||
local Items = require('Module:Items') | local Items = require('Module:Items') | ||
local weaponTypes = {'Magic Staff', 'Magic Wand', 'Ranged Weapon', 'Weapon'} | local weaponTypes = {'Magic Staff', 'Magic Wand', 'Ranged Weapon', 'Weapon'} | ||
Line 31: | Line 25: | ||
if(Shared.tableCount(itemList) == 0) then | if(Shared.tableCount(itemList) == 0) then | ||
return 'ERROR: you must select at least one item to get stats for' | return 'ERROR: you must select at least one item to get stats for[[Category:Pages with script errors]]' | ||
end | end | ||
local isWeaponType = Shared.contains(weaponTypes, itemList[1].type) | local isWeaponType = itemList[1].validSlots ~= nil and Shared.contains(itemList[1].validSlots, 'Weapon') and Shared.contains(weaponTypes, itemList[1].type) | ||
--Now that we have a preliminary list, let's figure out which columns are irrelevant (IE are zero for all items in the selection) | --Now that we have a preliminary list, let's figure out which columns are irrelevant (IE are zero for all items in the selection) | ||
Line 67: | Line 61: | ||
end | end | ||
end | end | ||
--Alright, let's start the table by building the shared header | --Alright, let's start the table by building the shared header | ||
local | local resultPart = {} | ||
table.insert(resultPart, '{| class="wikitable sortable stickyHeader"\r\n|-class="headerRow-0"') | |||
if isWeaponType then | if isWeaponType then | ||
--Weapons have extra columns here for Attack Speed and "Two Handed?" | --Weapons have extra columns here for Attack Speed and "Two Handed?" | ||
table.insert(resultPart, '\r\n!colspan="4"|') | |||
else | else | ||
table.insert(resultPart, '\r\n!colspan="2"|') | |||
end | end | ||
if attBonusCols > 0 then | if attBonusCols > 0 then | ||
table.insert(resultPart, '\r\n!colspan="'..attBonusCols..'"style="padding:0 0.5em 0 0.5em;"|Attack Bonus') | |||
end | end | ||
if strBonusCols > 0 then | if strBonusCols > 0 then | ||
table.insert(resultPart, '\r\n!colspan="'..strBonusCols..'"style="padding:0 0.5em 0 0.5em;"|Str. Bonus') | |||
end | end | ||
if Shared.contains(statColumns, 'magicDamageBonus') then | if Shared.contains(statColumns, 'magicDamageBonus') then | ||
table.insert(resultPart, '\r\n!colspan="1"style="padding:0 0.5em 0 0.5em;"|% Dmg Bonus') | |||
end | end | ||
if defBonusCols > 0 then | if defBonusCols > 0 then | ||
table.insert(resultPart, '\r\n!colspan="'..defBonusCols..'"style="padding:0 0.5em 0 0.5em;"|Defence Bonus') | |||
end | end | ||
if Shared.contains(statColumns, 'damageReduction') then | if Shared.contains(statColumns, 'damageReduction') then | ||
table.insert(resultPart, '\r\n!colspan="1"style="padding:0 0.5em 0 0.5em;"|DR') | |||
end | end | ||
if lvlReqCols > 0 then | if lvlReqCols > 0 then | ||
table.insert(resultPart, '\r\n!colspan="'..lvlReqCols..'"style="padding:0 0.5em 0 0.5em;"|Lvl Req') | |||
end | end | ||
if includeModifiers and includeDescription then | if includeModifiers and includeDescription then | ||
table.insert(resultPart, '\r\n!colspan="2"|') | |||
elseif includeModifiers or includeDescription then | elseif includeModifiers or includeDescription then | ||
table.insert(resultPart, '\r\n!colspan="1"|') | |||
end | end | ||
--One header row down, one to go | --One header row down, one to go | ||
table.insert(resultPart, '\r\n|-class="headerRow-1"') | |||
table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|Item') | |||
table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|Name') | |||
--Weapons have Attack Speed here | --Weapons have Attack Speed here | ||
if isWeaponType then | if isWeaponType then | ||
table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|Attack Speed') | |||
table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|Two Handed?') | |||
end | end | ||
--Attack bonuses | --Attack bonuses | ||
if Shared.contains(statColumns, 'slashAttackBonus') then | if Shared.contains(statColumns, 'slashAttackBonus') then | ||
table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Attack', type='skill', notext='true'})) | |||
end | end | ||
if Shared.contains(statColumns, 'stabAttackBonus') then | if Shared.contains(statColumns, 'stabAttackBonus') then | ||
table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Strength', type='skill', notext='true'})) | |||
end | end | ||
if Shared.contains(statColumns, 'blockAttackBonus') then | if Shared.contains(statColumns, 'blockAttackBonus') then | ||
table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Defence', type='skill', notext='true'})) | |||
end | end | ||
if Shared.contains(statColumns, 'rangedAttackBonus') then | if Shared.contains(statColumns, 'rangedAttackBonus') then | ||
table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Ranged', type='skill', notext='true'})) | |||
end | end | ||
if Shared.contains(statColumns, 'magicAttackBonus') then | if Shared.contains(statColumns, 'magicAttackBonus') then | ||
table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Magic', type='skill', notext='true'})) | |||
end | end | ||
--Strength bonuses | --Strength bonuses | ||
if Shared.contains(statColumns, 'strengthBonus') then | if Shared.contains(statColumns, 'strengthBonus') then | ||
table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Strength', type='skill', notext='true'})) | |||
end | end | ||
if Shared.contains(statColumns, 'rangedStrengthBonus') then | if Shared.contains(statColumns, 'rangedStrengthBonus') then | ||
table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Ranged', type='skill', notext='true'})) | |||
end | end | ||
if Shared.contains(statColumns, 'magicDamageBonus') then | if Shared.contains(statColumns, 'magicDamageBonus') then | ||
table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Magic', type='skill', notext='true'})) | |||
end | end | ||
--Defence bonuses | --Defence bonuses | ||
if Shared.contains(statColumns, 'defenceBonus') then | if Shared.contains(statColumns, 'defenceBonus') then | ||
table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Defence', type='skill', notext='true'})) | |||
end | end | ||
if Shared.contains(statColumns, 'rangedDefenceBonus') then | if Shared.contains(statColumns, 'rangedDefenceBonus') then | ||
table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Ranged', type='skill', notext='true'})) | |||
end | end | ||
if Shared.contains(statColumns, 'magicDefenceBonus') then | if Shared.contains(statColumns, 'magicDefenceBonus') then | ||
table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Magic', type='skill', notext='true'})) | |||
end | end | ||
if Shared.contains(statColumns, 'damageReduction') then | if Shared.contains(statColumns, 'damageReduction') then | ||
table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Defence', type='skill', notext='true'})) | |||
end | end | ||
--Level requirements | --Level requirements | ||
if Shared.contains(statColumns, 'attackLevelRequired') then | if Shared.contains(statColumns, 'attackLevelRequired') then | ||
table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Attack', type='skill', notext='true'})) | |||
end | end | ||
if Shared.contains(statColumns, 'defenceLevelRequired') then | if Shared.contains(statColumns, 'defenceLevelRequired') then | ||
table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Defence', type='skill', notext='true'})) | |||
end | end | ||
if Shared.contains(statColumns, 'rangedLevelRequired') then | if Shared.contains(statColumns, 'rangedLevelRequired') then | ||
table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Ranged', type='skill', notext='true'})) | |||
end | end | ||
if Shared.contains(statColumns, 'magicLevelRequired') then | if Shared.contains(statColumns, 'magicLevelRequired') then | ||
table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Magic', type='skill', notext='true'})) | |||
end | end | ||
--If includeModifiers is set to 'true', add the Modifiers column | --If includeModifiers is set to 'true', add the Modifiers column | ||
if includeModifiers then | if includeModifiers then | ||
table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|Modifiers') | |||
end | end | ||
--If includeDescription is set to 'true', add the Description column | --If includeDescription is set to 'true', add the Description column | ||
if includeDescription then | if includeDescription then | ||
table.insert(resultPart, '\r\n!style="padding:0 1em 0 0.5em;"|Description') | |||
end | end | ||
table.sort(itemList, function(a, b) return a.id < b.id end) | table.sort(itemList, function(a, b) return a.id < b.id end) | ||
Line 178: | Line 168: | ||
if isWeaponType then | if isWeaponType then | ||
--Building rows for weapons | --Building rows for weapons | ||
table.insert(resultPart, '\r\n|-') | |||
table.insert(resultPart, '\r\n|style ="text-align: left;padding: 0 0 0 0;"|'..Icons.Icon({item.name, type='item', size=50, notext=true})) | |||
table.insert(resultPart, '\r\n|style ="text-align: left;padding: 0 0.5em 0 0.5em;"|[['..item.name..']]') | |||
table.insert(resultPart, '\r\n| style ="text-align: right;padding: 0 0.5em 0 0;" |'..Shared.formatnum(Items._getItemStat(item, 'attackSpeed', true))) | |||
--That's the first list out of the way, now for 2-Handed | --That's the first list out of the way, now for 2-Handed | ||
table.insert(resultPart, '\r\n| style ="text-align: right;"|') | |||
table.insert(resultPart, Items._getItemStat(item, 'isTwoHanded') and 'Yes' or 'No') | |||
for j, statName in pairs(statColumns) do | for j, statName in pairs(statColumns) do | ||
local statValue = Items._getItemStat(item, statName, true) | local statValue = Items._getItemStat(item, statName, true) | ||
table.insert(resultPart, '\r\n| style ="text-align: right;padding: 0 0.5em 0 0;') | |||
if | if string.find(statName, '^(.+)LevelRequired$') == nil then | ||
if statValue > 0 then | if statValue > 0 then | ||
table.insert(resultPart, 'background-color:lightgreen;') | |||
elseif statValue < 0 then | elseif statValue < 0 then | ||
table.insert(resultPart, 'background-color:lightpink;') | |||
end | end | ||
end | end | ||
table.insert(resultPart, '"|'..Shared.formatnum(statValue)) | |||
if statName == 'magicDamageBonus' or statName == 'damageReduction' then | if statName == 'magicDamageBonus' or statName == 'damageReduction' then table.insert(resultPart, '%') end | ||
end | end | ||
--If requested, add the item Modifiers | --If requested, add the item Modifiers | ||
if includeModifiers then | if includeModifiers then | ||
table.insert(resultPart, '\r\n|style="text-align:left;white-space:nowrap;padding:0 0.5em 0 0.5em;"|') | |||
table.insert(resultPart, Constants.getModifiersText(item.modifiers, true)) | |||
end | end | ||
--If requested, add description | --If requested, add description | ||
if includeDescription then | if includeDescription then | ||
table.insert(resultPart, '\r\n|style="text-align:left;padding:0 0.5em 0 0.5em;"|') | |||
table.insert(resultPart, item.description ~= nil and item.description or '') | |||
end | end | ||
else | else | ||
--Building rows for armour | --Building rows for armour | ||
table.insert(resultPart, '\r\n|-') | |||
table.insert(resultPart, '\r\n|style ="text-align: left;padding: 0 0 0 0;"|'..Icons.Icon({item.name, type='item', size=50, notext=true})) | |||
table.insert(resultPart, '\r\n|style ="text-align: left;padding: 0 0.5em 0 0.5em;"|[['..item.name..']]') | |||
for j, statName in pairs(statColumns) do | for j, statName in pairs(statColumns) do | ||
local statValue = Items._getItemStat(item, statName, true) | local statValue = Items._getItemStat(item, statName, true) | ||
table.insert(resultPart, '\r\n| style ="text-align: right;padding: 0 0.5em 0 0;') | |||
if statValue > 0 then | if statValue > 0 then | ||
table.insert(resultPart, 'background-color:lightgreen;') | |||
elseif statValue < 0 then | elseif statValue < 0 then | ||
table.insert(resultPart, 'background-color:lightpink;') | |||
end | end | ||
table.insert(resultPart, '"|'..Shared.formatnum(statValue)) | |||
if statName == 'magicDamageBonus' or statName == 'damageReduction' then | if statName == 'magicDamageBonus' or statName == 'damageReduction' then table.insert(resultPart, '%') end | ||
end | end | ||
--If requested, add the item Modifiers | --If requested, add the item Modifiers | ||
if includeModifiers then | if includeModifiers then | ||
table.insert(resultPart, '\r\n|style="text-align:left;white-space:nowrap;padding:0 0.5em 0 0.5em;"|') | |||
table.insert(resultPart, Constants.getModifiersText(item.modifiers, true)) | |||
end | end | ||
--If requested, add description | --If requested, add description | ||
if includeDescription then | if includeDescription then | ||
table.insert(resultPart, '\r\n|style="text-align:left;padding:0 0.5em 0 0.5em;"|') | |||
table.insert(resultPart, item.description ~= nil and item.description or '') | |||
end | end | ||
end | end | ||
end | end | ||
table.insert(resultPart, '\r\n|}') | |||
return | |||
return table.concat(resultPart) | |||
end | end | ||
Line 251: | Line 236: | ||
local type = args.type | local type = args.type | ||
local tier = args.tier | local tier = args.tier | ||
local | local slot = args.slot | ||
local ammoTypeStr = args.ammoType | local ammoTypeStr = args.ammoType | ||
local category = args.category ~= nil and args.category or 'Combat' | local category = args.category ~= nil and args.category or 'Combat' | ||
Line 269: | Line 254: | ||
end | end | ||
local isWeaponType = Shared.contains(weaponTypes, type) | local isWeaponType = Shared.contains(weaponTypes, type) | ||
Line 289: | Line 268: | ||
--Now for handling armour | --Now for handling armour | ||
if type == "Armour" or type == "Melee" then | if type == "Armour" or type == "Melee" then | ||
listItem = item | listItem = Items._getItemStat(item, 'defenceLevelRequired') ~= nil or (item.category == 'Combat' and item.type == 'Armour') | ||
elseif type == "Ranged Armour" or type == "Ranged" then | elseif type == "Ranged Armour" or type == "Ranged" then | ||
listItem = item | listItem = Items._getItemStat(item, 'rangedLevelRequired') ~= nil or (item.category == 'Combat' and item.type == 'Ranged Armour') | ||
elseif type == "Magic Armour" or type == "Magic" then | elseif type == "Magic Armour" or type == "Magic" then | ||
listItem = item | listItem = Items._getItemStat(item, 'magicLevelRequired') or (item.category == 'Combat' and item.type == 'Magic Armour') | ||
else | else | ||
listItem = item.type == type and item.category ~= 'Combat' | listItem = item.type == type and item.category ~= 'Combat' | ||
end | end | ||
if ammoType ~= nil then listItem = listItem and item.ammoType == ammoType end | if ammoType ~= nil then listItem = listItem and item.ammoType == ammoType end | ||
if slot ~= nil then listItem = listItem and item. | if slot ~= nil then listItem = listItem and Shared.contains(item.validSlots, slot) end | ||
end | end | ||
if listItem then | if listItem then | ||
Line 305: | Line 284: | ||
end | end | ||
local result = p._getEquipmentTable(itemList).."[[Category:getEquipmentTable]]" | |||
return result | |||
end | end | ||
function p._getCategoryTable(style, slot, other, includeModifiers, includeDescription) | function p._getCategoryTable(style, slot, other, includeModifiers, includeDescription) | ||
if type(slot) == ' | if type(slot) == 'number' then | ||
slot = Constants. | slot = Constants.getEquipmentSlotName(slot) | ||
end | end | ||
Line 316: | Line 297: | ||
local isMatch = true | local isMatch = true | ||
if style == 'Melee' then | if style == 'Melee' then | ||
if (item | if (Items._getItemStat(item, 'defenceLevelRequired') == nil and Items._getItemStat(item, 'attackLevelRequired') == nil) and not Shared.contains(styleOverrides.Melee, item.name) then isMatch = false end | ||
elseif style == 'Ranged' then | elseif style == 'Ranged' then | ||
if item | if Items._getItemStat(item, 'rangedLevelRequired') == nil and not Shared.contains(styleOverrides.Ranged, item.name) then isMatch = false end | ||
elseif style == 'Magic' then | elseif style == 'Magic' then | ||
if item | if Items._getItemStat(item, 'magicLevelRequired') == nil and not Shared.contains(styleOverrides.Magic, item.name) then isMatch = false end | ||
elseif style == 'None' then | elseif style == 'None' then | ||
if (item | if (Items._getItemStat(item, 'defenceLevelRequired') ~= nil or Items._getItemStat(item, 'rangedLevelRequired') ~= nil or Items._getItemStat(item, 'magicLevelRequired') ~= nil or | ||
Shared.contains(styleOverrides.Melee, item.name) or Shared.contains(styleOverrides.Ranged, item.name) or Shared.contains(styleOverrides.Magic, item.name)) and | Shared.contains(styleOverrides.Melee, item.name) or Shared.contains(styleOverrides.Ranged, item.name) or Shared.contains(styleOverrides.Magic, item.name)) and | ||
not Shared.contains(styleOverrides.None, item.name) then | not Shared.contains(styleOverrides.None, item.name) then | ||
Line 328: | Line 309: | ||
end | end | ||
end | end | ||
if slot == nil or not Shared.contains(item.validSlots, slot) then isMatch = false end | |||
if slot == nil or | |||
if isMatch and other ~= nil then | if isMatch and other ~= nil then | ||
if slot == | if slot == 'Weapon' then --For quiver slot or weapon slot, 'other' is the ammo type | ||
if other == 'Arrows' then | if other == 'Arrows' then | ||
if item.ammoTypeRequired ~= 0 then isMatch = false end | if item.ammoTypeRequired ~= 0 then isMatch = false end | ||
Line 338: | Line 318: | ||
if item.ammoTypeRequired ~= 1 then isMatch = false end | if item.ammoTypeRequired ~= 1 then isMatch = false end | ||
end | end | ||
elseif slot == | elseif slot == 'Quiver' then | ||
if other == 'Arrows' then | if other == 'Arrows' then | ||
if item.ammoType ~= 0 then isMatch = false end | if item.ammoType ~= 0 then isMatch = false end | ||
Line 356: | Line 336: | ||
end) | end) | ||
local result = p._getEquipmentTable(itemList, includeModifiers, includeDescription) | |||
return result | |||
end | end | ||
Line 380: | Line 362: | ||
local itemList = {} | local itemList = {} | ||
local errMsg = 'ERROR: Some items not found in database: ' | local errMsg = 'ERROR: Some items not found in database: [[Category:Pages with script errors]]' | ||
local hasErr = false | local hasErr = false | ||
for i, name in Shared.skpairs(itemNames) do | for i, name in Shared.skpairs(itemNames) do | ||
Line 397: | Line 379: | ||
return p._getEquipmentTable(itemList, includeModifiers) | return p._getEquipmentTable(itemList, includeModifiers) | ||
end | end | ||
end | end | ||
Line 455: | Line 396: | ||
--Unfortunately just gonna have to manually check all the changes I think... | --Unfortunately just gonna have to manually check all the changes I think... | ||
local | local statList = { | ||
-- {'statName', 'statDescription'} | |||
{'stabAttackBonus', '{V} '..Icons.Icon({'Melee', notext=true})..' Stab Bonus'}, | |||
{'slashAttackBonus', '{V} '..Icons.Icon({'Melee', notext=true})..' Slash Bonus'}, | |||
{'blockAttackBonus', '{V} '..Icons.Icon({'Melee', notext=true})..' Block Bonus'}, | |||
{'meleeStrengthBonus', '{V} '..Icons.Icon({'Strength', type='skill', notext=true})..' Strength Bonus'}, | |||
{'rangedStrengthBonus', '{V} '..Icons.Icon({'Ranged', type='skill', notext=true})..' Strength Bonus'}, | |||
{'magicStrengthBonus', '{V}% '..Icons.Icon({'Magic', type='skill', notext=true})..' Damage Bonus'}, | |||
{'meleeDefenceBonus', '{V} '..Icons.Icon({'Defence', type='skill', notext=true})..' Defence Bonus'}, | |||
{'rangedDefenceBonus', '{V} '..Icons.Icon({'Ranged', type='skill', notext=true})..' Defence Bonus'}, | |||
{'magicDefenceBonus', '{V} '..Icons.Icon({'Magic', type='skill', notext=true})..' Defence Bonus'}, | |||
{'damageReduction', '{V}% Damage Reduction'}, | |||
{'increasedSlayerXP', '{V}% '..Icons.Icon({'Slayer', type='skill', notext=true})..' Bonus XP'}, | |||
{'attackLevelRequired', '{V} '..Icons.Icon({'Attack', type='skill', notext=true})..' Level Required'}, | |||
{'defenceLevelRequired', '{V} '..Icons.Icon({'Defence', type='skill', notext=true})..' Level Required'}, | |||
{'rangedLevelRequired', '{V} '..Icons.Icon({'Ranged', type='skill', notext=true})..' Level Required'}, | |||
{'magicLevelRequired', '{V} '..Icons.Icon({'Magic', type='skill', notext=true})..' Level Required'}, | |||
} | |||
for i, stat in ipairs(statList) do | |||
if stat[1] == 'increasedSlayerXP' then | |||
getSpecificStatString(Items._getItemModifier(item1, stat[1], 'Slayer'), Items._getItemModifier(item2, stat[1], 'Slayer'), stat[2]) | |||
else | |||
getSpecificStatString(Items._getItemStat(item1, stat[1]), Items._getItemStat(item2, stat[1]), stat[2]) | |||
end | |||
end | |||
return table.concat(changeArray, '<br/>') | return table.concat(changeArray, '<br/>') | ||
Line 490: | Line 433: | ||
itemArray = Items.getItems(function(item) return Shared.contains(item.name, 'Potion') and item.itemsRequired ~= nil end) | itemArray = Items.getItems(function(item) return Shared.contains(item.name, 'Potion') and item.itemsRequired ~= nil end) | ||
elseif string.upper(category) == 'OTHER' then | elseif string.upper(category) == 'OTHER' then | ||
itemArray = Items.getItems(function(item) | itemArray = Items.getItems(function(item) | ||
return not Shared.contains(item.name, 'Potion') and item.itemsRequired ~= nil and item. | return not Shared.contains(item.name, 'Potion') and item.itemsRequired ~= nil and item.validSlots == nil | ||
end) | end) | ||
else | else | ||
if Constants.getEquipmentSlotID(category) == nil then | |||
return 'ERROR: Invalid option. Choose either an equipment slot, Potion, or Other[[Category:Pages with script errors]]' | return 'ERROR: Invalid option. Choose either an equipment slot, Potion, or Other[[Category:Pages with script errors]]' | ||
end | end | ||
isEquipment = true | isEquipment = true | ||
itemArray = Items.getItems(function(item) | itemArray = Items.getItems(function(item) | ||
return item.itemsRequired ~= nil and item. | return item.itemsRequired ~= nil and Shared.contains(item.validSlots, category) | ||
end) | end) | ||
end | end | ||
table.sort(itemArray, function(a, b) return a.id < b.id end) | table.sort(itemArray, function(a, b) return a.id < b.id end) | ||
local | local resultPart = {} | ||
table.insert(resultPart, '{| class="wikitable sortable stickyHeader"') | |||
table.insert(resultPart, '\r\n|- class="headerRow-0"') | |||
if isEquipment then | table.insert(resultPart, '\r\n!colspan="2"|Upgraded Item!!Ingredients') | ||
if isEquipment then table.insert(resultPart, '!!Stat Change') end | |||
for i, item in Shared.skpairs(itemArray) do | for i, item in Shared.skpairs(itemArray) do | ||
table.insert(resultPart, '\r\n|-') | |||
table.insert(resultPart, '\r\n|'..Icons.Icon({item.name, type='item', size='50', notext=true})..'||[['..item.name..']]') | |||
local matArray = {} | local matArray = {} | ||
Line 520: | Line 463: | ||
table.insert(matArray, Icons.Icon({mat.name, type='item', qty=row[2]})) | table.insert(matArray, Icons.Icon({mat.name, type='item', qty=row[2]})) | ||
if item. | if item.validSlots ~= nil and mat.validSlots ~= nil and statChangeString == '' then | ||
statChangeString = p.getStatChangeString(item, mat) | statChangeString = p.getStatChangeString(item, mat) | ||
end | end | ||
Line 527: | Line 470: | ||
table.insert(matArray, Icons.GP(item.trimmedGPCost)) | table.insert(matArray, Icons.GP(item.trimmedGPCost)) | ||
end | end | ||
table.insert(resultPart, '||'..table.concat(matArray, '<br/>')) | |||
if isEquipment then | if isEquipment then | ||
table.insert(resultPart, '||'..statChangeString) | |||
end | end | ||
end | end | ||
table.insert(resultPart, '\r\n|}') | |||
return | return table.concat(resultPart) | ||
end | end | ||
return p | return p |