4,951
edits
Falterfire (talk | contribs) (format fix) |
Falterfire (talk | contribs) (Added Shop table for item sources) |
||
Line 23: | Line 23: | ||
--Items (aside from bars & gems) which can be created via Alt Magic | --Items (aside from bars & gems) which can be created via Alt Magic | ||
local AltMagicProducts = {'Rune Essence', 'Bones', 'Holy Dust'} | local AltMagicProducts = {'Rune Essence', 'Bones', 'Holy Dust'} | ||
--The kinds of gloves with cost & charges | |||
local GloveTable = {['Cooking Gloves'] = {cost=50000, charges=500}, | |||
['Mining Gloves'] = {cost=75000, charges=500}, | |||
['Smithing Gloves'] = {cost=100000, charges=500}, | |||
['Thieving Gloves'] = {cost=100000, charges=500}, | |||
['Gem Gloves'] = {cost=500000, charges=2000}} | |||
Line 999: | Line 1,005: | ||
return p._getItemLootSourceTable(item) | return p._getItemLootSourceTable(item) | ||
end | |||
function p._getItemShopTable(item) | |||
local result = '{| class="wikitable"\r\n|-\r\n!colspan="2"|[[Shop]] Purchase' | |||
result = result..'\r\n|-\r\n!style="text-align:right;"|Cost\r\n|' | |||
local cost = {} | |||
local qty = '1' | |||
if item.buysFor ~= nil then | |||
if item.buysFor > 0 then table.insert(cost, Icons.GP(item.buysFor)) end | |||
elseif item.slayerCost ~= nil then | |||
table.insert(cost, Icons.Icon({'Slayer Coins', qty=item.slayerCost, notext='true'})) | |||
elseif GloveTable[item.name] ~= nil then | |||
table.insert(cost, Icons.GP(GloveTable[item.name].cost)) | |||
qty = '+'..Shared.formatnum(GloveTable[item.name].charges)..' Charges' | |||
end | |||
if item.buysForLeather ~= nil then | |||
table.insert(cost, Icons.Icon({'Leather', type='item', qty=item.buysForLeather})) | |||
end | |||
if item.buysForItems ~= nil then | |||
for i, row in pairs(item.buysForItems) do | |||
local mat = p.getItemByID(row[1]) | |||
table.insert(cost, Icons.Icon({mat.name, type='item', qty=row[2]})) | |||
end | |||
end | |||
if Shared.tableCount(cost) == 0 then | |||
--If no cost is set, return an empty string | |||
return '' | |||
else | |||
result = result..table.concat(cost, '<br/>') | |||
end | |||
--For right now, only have requirements on Skillcapes | |||
result = result..'\r\n|-\r\n!style="text-align:right;"|Requirements\r\n|' | |||
if item.name == 'Max Skillcape' then | |||
result = result..'Level 99 in all [[Skills]]' | |||
elseif Shared.contains(item.name, 'Skillcape') then | |||
local skillName = Shared.splitString(item.name)[1] | |||
result = result..Icons._SkillReq(skillName, 99) | |||
else | |||
result = result..'None' | |||
end | |||
result = result..'\r\n|-\r\n!style="text-align:right;"|Quantity\r\n|'..qty | |||
result = result..'\r\n|}' | |||
return result | |||
end | |||
function p.getItemShopTable(frame) | |||
local itemName = frame.args ~= nil and frame.args[1] or frame | |||
local item = p.getItem(itemName) | |||
if item == nil then | |||
return "ERROR: No item named "..itemName.." exists in the data module" | |||
end | |||
return p._getItemShopTable(item) | |||
end | end | ||
Line 1,040: | Line 1,101: | ||
function p._getItemSourceTables(item) | function p._getItemSourceTables(item) | ||
local result = '' | local result = '' | ||
local shopTable = p._getItemShopTable(item) | |||
if string.len(shopTable) > 0 then | |||
result = result..'===Shop===\r\n'..shopTable | |||
end | |||
local creationTable = p._getCreationTable(item) | local creationTable = p._getCreationTable(item) | ||
if string.len(creationTable) > 0 then result = result..'===Creation===\r\n'..creationTable end | if string.len(creationTable) > 0 then | ||
if string.len(result) > 0 then result = result..'\r\n' end | |||
result = result..'===Creation===\r\n'..creationTable | |||
end | |||
local upgradeTable = p._getItemUpgradeTable(item) | local upgradeTable = p._getItemUpgradeTable(item) | ||
if string.len(upgradeTable) > 0 then | if string.len(upgradeTable) > 0 then | ||
if string.len(result) > 0 then | if string.len(result) > 0 then result = result..'\r\n' end | ||
if string.len(creationTable) == 0 then result = result..'===Creation===\r\n' end | |||
result = result..upgradeTable | result = result..upgradeTable | ||
end | end |