17,097
edits
(_getItemUses: Only iterate over slayer areas for equipment) |
(_getItemUseTable: Avoid repeated string concatenation) |
||
Line 483: | Line 483: | ||
local spellUseTable = p._getSpellUseTable(item) | local spellUseTable = p._getSpellUseTable(item) | ||
local | local resultPart = {} | ||
if Shared.tableCount(useArray) == 0 and Shared.tableCount(obstacles) == 0 then | if Shared.tableCount(useArray) == 0 and Shared.tableCount(obstacles) == 0 then | ||
if string.len(spellUseTable) > 0 then | if string.len(spellUseTable) > 0 then | ||
Line 491: | Line 491: | ||
end | end | ||
end | end | ||
table.insert(resultPart, '{| class="wikitable sortable"') | |||
table.insert(resultPart, '\r\n!colspan=2|Item Created!!Type!!Requirements!!XP!!Ingredients') | |||
for i, row in pairs(useArray) do | for i, row in pairs(useArray) do | ||
local qty = row.qty ~= nil and row.qty or 1 | local qty = row.qty ~= nil and row.qty or 1 | ||
local iconType = row.type ~= nil and row.type or 'item' | local iconType = row.type ~= nil and row.type or 'item' | ||
table.insert(resultPart, '\r\n|-\r\n|data-sort-value="'..row.item.name..'"|') | |||
table.insert(resultPart, Icons.Icon({row.item.name, type=iconType, notext=true, size=50})..'||') | |||
if qty > 1 then | if qty > 1 then table.insert(resultPart, "'''"..qty.."x''' ") end | ||
table.insert(resultPart, '[['..row.item.name..']]') | |||
if row.skill == 'Upgrade' then | if row.skill == 'Upgrade' then | ||
table.insert(resultPart, '||data-sort-value="Upgrade"|[[Upgrading Items|Upgrade]]') | |||
elseif row.skill == 'Shop' then | elseif row.skill == 'Shop' then | ||
table.insert(resultPart, '||data-sort-value="Shop"|'..Icons.Icon({'Shop'})) | |||
else | else | ||
table.insert(resultPart, '||data-sort-value="'..row.skill..'"|'..Icons.Icon({row.skill, type='skill'})) | |||
end | end | ||
if type(row.req) == 'number' then | if type(row.req) == 'number' then | ||
table.insert(resultPart, '|| data-sort-value="'..row.req..'"|'..Icons._SkillReq(row.skill, row.req)) | |||
elseif row.reqVal ~= nil then | elseif row.reqVal ~= nil then | ||
table.insert(resultPart, '|| data-sort-value="'..row.reqVal..'"|'..row.req) | |||
else | else | ||
table.insert(resultPart, '||'..row.req) | |||
end | end | ||
if type(row.xp) == 'string' then | if type(row.xp) == 'string' then | ||
table.insert(resultPart, '||data-sort-value="0"|'..row.xp) | |||
else | else | ||
table.insert(resultPart, '||data-sort-value="'..row.xp..'"|'..row.xp..' '..Icons.Icon({row.skill, type='skill', notext=true})..' XP') | |||
end | end | ||
table.insert(resultPart, '||') | |||
for i, mat in Shared.skpairs(row.mats) do | for i, mat in Shared.skpairs(row.mats) do | ||
local matID = mat.id ~= nil and mat.id or mat[1] | local matID = mat.id ~= nil and mat.id or mat[1] | ||
Line 525: | Line 525: | ||
local matText = '' | local matText = '' | ||
if i > 1 then | if i > 1 then table.insert(resultPart, '<br/>') end | ||
if matID >= 0 then | if matID >= 0 then | ||
-- Item | -- Item | ||
Line 543: | Line 543: | ||
matText = 'ERROR: Unknown item ID: ' .. matID .. ' [[Category:Pages with Script Errors]]' | matText = 'ERROR: Unknown item ID: ' .. matID .. ' [[Category:Pages with Script Errors]]' | ||
end | end | ||
table.insert(resultPart, matText) | |||
end | end | ||
if row.gp ~= nil then | if row.gp ~= nil then table.insert(resultPart, '<br/>'..Icons.GP(row.gp)) end | ||
end | end | ||
--Agility obstacles are weird and get their own section | --Agility obstacles are weird and get their own section | ||
for i, obst in Shared.skpairs(obstacles) do | for i, obst in Shared.skpairs(obstacles) do | ||
table.insert(resultPart, '\r\n|-\r\n|') | |||
table.insert(resultPart, Icons.Icon({"Agility", type="skill", size="50", notext=true})) | |||
table.insert(resultPart, '||[[Agility#Obstacles|'..obst.name..']]') | |||
table.insert(resultPart, '||'..Icons.Icon({"Agility", type="skill"})) | |||
--Adding the requirements for the Agility Obstacle | --Adding the requirements for the Agility Obstacle | ||
Line 568: | Line 568: | ||
end | end | ||
end | end | ||
table.insert(resultPart, '||'..table.concat(reqArray, '<br/>')) | |||
--Just including 'N/A' for XP since it doesn't really apply for Agility Obstacles | --Just including 'N/A' for XP since it doesn't really apply for Agility Obstacles | ||
table.insert(resultPart, '||N/A') | |||
--Finally the cost | --Finally the cost | ||
Line 587: | Line 587: | ||
end | end | ||
table.insert(resultPart, '||'..table.concat(costArray, '<br/>')) | |||
end | end | ||
table.insert(resultPart, '\r\n|}') | |||
if string.len(spellUseTable) > 0 then | if string.len(spellUseTable) > 0 then | ||
table.insert(resultPart, '\r\n==='..Icons.Icon({'Magic', type='skill', size='30'})..'===\r\n'..spellUseTable) | |||
end | end | ||
return '==Uses==\r\n'.. | return '==Uses==\r\n'..table.concat(resultPart) | ||
end | end | ||