17,097
edits
(_getItemUseTable: Avoid repeated string concatenation) |
No edit summary |
||
Line 77: | Line 77: | ||
--Before anything else, if this is a potion add it to the appropriate override section | --Before anything else, if this is a potion add it to the appropriate override section | ||
if item. | if item.herbloreMasteryID ~= nil then | ||
table.insert(itemUseArray[potionUseArray[item. | table.insert(itemUseArray[potionUseArray[item.herbloreMasteryID]], item.name) | ||
end | end | ||
Line 101: | Line 101: | ||
if item.dropTable ~= nil then | if item.dropTable ~= nil then | ||
table.insert(categoryArray, '[[Category:Openable Items]]') | table.insert(categoryArray, '[[Category:Openable Items]]') | ||
table.insert(useArray, chr..'[[Chest Drop Tables|Can Be Opened]]') | table.insert(useArray, chr..'[[Chest Drop Tables|Can Be Opened]]') | ||
end | end | ||
Line 177: | Line 160: | ||
end | end | ||
end | end | ||
if item2.summoningReq ~= nil then | if item2.summoningReq ~= nil then | ||
for j, reqSet in pairs(item2.summoningReq) do | for j, reqSet in pairs(item2.summoningReq) do | ||
Line 192: | Line 175: | ||
--Check if Agility applies here | --Check if Agility applies here | ||
canAgile = Shared.tableCount(Agility.getObstaclesForItem(item.id)) > 0 | canAgile = Shared.tableCount(Agility.getObstaclesForItem(item.id)) > 0 | ||
--Agility | --Agility | ||
if canAgile or Shared.contains(itemUseArray.Agility, item.name) then | if canAgile or Shared.contains(itemUseArray.Agility, item.name) then | ||
Line 210: | Line 193: | ||
end | end | ||
--Firemaking | --Firemaking | ||
if item. | if SkillData.Firemaking[item.id + 1] ~= nil or Shared.contains(itemUseArray.Firemaking, item.name) then | ||
table.insert(useArray, chr..Icons.Icon({'Firemaking', type='skill'})) | table.insert(useArray, chr..Icons.Icon({'Firemaking', type='skill'})) | ||
end | end | ||
Line 239: | Line 222: | ||
end | end | ||
--Slayer | --Slayer | ||
if | if item.slayerCost ~= nil or Shared.contains(itemUseArray.Slayer, item.name) then | ||
table.insert(useArray, chr..Icons.Icon({'Slayer', type='skill'})) | table.insert(useArray, chr..Icons.Icon({'Slayer', type='skill'})) | ||
end | end | ||
Line 258: | Line 241: | ||
table.insert(useArray, chr..Icons.Icon({'Woodcutting', type='skill'})) | table.insert(useArray, chr..Icons.Icon({'Woodcutting', type='skill'})) | ||
end | end | ||
--Other odds and ends: | --Other odds and ends: | ||
--Mastery Tokens are tied to 'Mastery' | --Mastery Tokens are tied to 'Mastery' | ||
if item. | if item.type == 'Token' then | ||
table.insert(useArray, chr..Icons.Icon({'Mastery'})) | table.insert(useArray, chr..Icons.Icon({'Mastery'})) | ||
end | end | ||
Line 269: | Line 252: | ||
--Except Max Skillcape, which is tied to all skills. (And so is the Signet Ring) | --Except Max Skillcape, which is tied to all skills. (And so is the Signet Ring) | ||
--And combat skillcapes, since combat skills don't get special treatment | --And combat skillcapes, since combat skills don't get special treatment | ||
local ignoreCapes = {'Ranged Skillcape', 'Attack Skillcape', 'Strength Skillcape', 'Hitpoints Skillcape', 'Defence Skillcape'} | local ignoreCapes = {'Ranged Skillcape', 'Attack Skillcape', 'Strength Skillcape', 'Hitpoints Skillcape', 'Defence Skillcape'} | ||
if | if item.name == 'Max Skillcape' or item.name == 'Aorpheat's Signet Ring' or item.name == 'Cape of Completion' then | ||
table.insert(useArray, chr..'All skills') | table.insert(useArray, chr..'All skills') | ||
elseif item.name == 'Magic Skillcape' then | elseif item.name == 'Magic Skillcape' then | ||
Line 314: | Line 297: | ||
local addCategories = false | local addCategories = false | ||
local asList = true | local asList = true | ||
if frame.args ~= nil then | if frame.args ~= nil then | ||
addCategories = frame.args.addCategories ~= nil and frame.args.addCategories ~= '' and frame.args.addCategories ~= 'false' | addCategories = frame.args.addCategories ~= nil and frame.args.addCategories ~= '' and frame.args.addCategories ~= 'false' | ||
asList = frame.args.addCategories == nil or frame.args.addCategories == '' or frame.args.addCategories == 'true' | asList = frame.args.addCategories == nil or frame.args.addCategories == '' or frame.args.addCategories == 'true' | ||
Line 402: | Line 385: | ||
for j, req in pairs(item2.herbloreReq) do | for j, req in pairs(item2.herbloreReq) do | ||
if req.id == item.id then | if req.id == item.id then | ||
local potionData = SkillData.Herblore.ItemData[item2. | local potionData = SkillData.Herblore.ItemData[item2.herbloreMasteryID + 1] | ||
local mat = item2.herbloreReq | local mat = item2.herbloreReq | ||
local xp = potionData.herbloreXP | local xp = potionData.herbloreXP | ||
Line 425: | Line 408: | ||
mat[k].qty = math.max(math.floor(1000 / math.max(item.sellsFor, 20)), 1) | mat[k].qty = math.max(math.floor(1000 / math.max(item.sellsFor, 20)), 1) | ||
local xp = 5 + 2 * math.floor(item2.summoningLevel * 0.2) | local xp = 5 + 2 * math.floor(item2.summoningLevel * 0.2) | ||
local rowReq = item2.summoningLevel | local rowReq = Icons._SkillReq('Summoning', item2.summoningLevel) | ||
table.insert(useArray, {item = item2, qty = 25, mats = mat, skill = 'Summoning', req = rowReq, xp = xp}) | table.insert(useArray, {item = item2, qty = 25, mats = mat, skill = 'Summoning', reqVal = item2.summoningLevel, req = rowReq, xp = xp}) | ||
end | end | ||
end | end | ||
Line 483: | Line 466: | ||
local spellUseTable = p._getSpellUseTable(item) | local spellUseTable = p._getSpellUseTable(item) | ||
local | local result = '' | ||
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 474: | ||
end | end | ||
end | end | ||
result = result..'{| class="wikitable sortable"' | |||
result = result..'\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' | ||
result = result..'\r\n|-\r\n|data-sort-value="'..row.item.name..'"|' | |||
result = result..Icons.Icon({row.item.name, type=iconType, notext=true, size=50})..'||' | |||
if qty > 1 then | if qty > 1 then result = result.."'''"..qty.."x''' " end | ||
result = result..'[['..row.item.name..']]' | |||
if row.skill == 'Upgrade' then | if row.skill == 'Upgrade' then | ||
result = result..'||data-sort-value="Upgrade"|[[Upgrading Items|Upgrade]]' | |||
elseif row.skill == 'Shop' then | elseif row.skill == 'Shop' then | ||
result = result..'||data-sort-value="Shop"|'..Icons.Icon({'Shop'}) | |||
else | else | ||
result = result..'||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 | ||
result = result..'|| data-sort-value="'..row.req..'"|'..Icons._SkillReq(row.skill, row.req) | |||
elseif row.reqVal ~= nil then | elseif row.reqVal ~= nil then | ||
result = result..'|| data-sort-value="'..row.reqVal..'"|'..row.req | |||
else | else | ||
result = result..'||'..row.req | |||
end | end | ||
if type(row.xp) == 'string' then | if type(row.xp) == 'string' then | ||
result = result..'||data-sort-value="0"|'..row.xp | |||
else | else | ||
result = result..'||data-sort-value="'..row.xp..'"|'..row.xp..' '..Icons.Icon({row.skill, type='skill', notext=true})..' XP' | |||
end | end | ||
result = result..'||' | |||
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] | ||
local matQty = mat.qty ~= nil and mat.qty or mat[2] | local matQty = mat.qty ~= nil and mat.qty or mat[2] | ||
local matText = '' | local matText = '' | ||
if i > 1 then | if i > 1 then result = result..'<br/>' end | ||
if matID >= 0 then | if matID >= 0 then | ||
-- Item | -- Item | ||
Line 543: | Line 526: | ||
matText = 'ERROR: Unknown item ID: ' .. matID .. ' [[Category:Pages with Script Errors]]' | matText = 'ERROR: Unknown item ID: ' .. matID .. ' [[Category:Pages with Script Errors]]' | ||
end | end | ||
result = result .. matText | |||
end | end | ||
if row.gp ~= nil then | if row.gp ~= nil then result = result..'<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 | ||
result = result..'\r\n|-\r\n|' | |||
result = result..Icons.Icon({"Agility", type="skill", size="50", notext=true}) | |||
result = result..'||[[Agility#Obstacles|'..obst.name..']]' | |||
result = result..'||'..Icons.Icon({"Agility", type="skill"}) | |||
--Adding the requirements for the Agility Obstacle | --Adding the requirements for the Agility Obstacle | ||
Line 568: | Line 551: | ||
end | end | ||
end | end | ||
result = result..'||'..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 | ||
result = result..'||N/A' | |||
--Finally the cost | --Finally the cost | ||
Line 586: | Line 569: | ||
table.insert(costArray, Icons.Icon({item.name, type="item", qty=mat[2]})) | table.insert(costArray, Icons.Icon({item.name, type="item", qty=mat[2]})) | ||
end | end | ||
result = result..'||'..table.concat(costArray, '<br/>') | |||
end | end | ||
result = result..'\r\n|}' | |||
if string.len(spellUseTable) > 0 then | if string.len(spellUseTable) > 0 then | ||
result = result..'\r\n==='..Icons.Icon({'Magic', type='skill', size='30'})..'===\r\n'..spellUseTable | |||
end | end | ||
return '==Uses==\r\n'.. | return '==Uses==\r\n'..result | ||
end | end | ||