17,101
edits
(getPurchaseContents: Initial implementation) |
(getPurchaseStat: Special handling for 'cost' stat) |
||
Line 61: | Line 61: | ||
local statName = args[2] | local statName = args[2] | ||
local displayInline = (args['inline'] ~= nil and string.lower(args['inline']) == 'true' or false) | local displayInline = (args['inline'] ~= nil and string.lower(args['inline']) == 'true' or false) | ||
local | -- Hack for some purchases existing twice with varying costs (e.g. 'Extra Equipment Set') | ||
local purchaseList = {} | |||
if statName == 'cost' then | |||
purchaseList = p.getPurchases(function(cat, purch) return purch.name == purchaseName end) | |||
else | |||
purchaseList = {p.getPurchase(purchaseName)} | |||
end | |||
if | if Shared.tableCount(purchaseList) == 0 then | ||
return "ERROR: Couldn't find purchase with name '" .. purchaseName .. "'[[Category:Pages with script errors]]" | return "ERROR: Couldn't find purchase with name '" .. purchaseName .. "'[[Category:Pages with script errors]]" | ||
else | else | ||
local resultPart = {} | |||
for i, purchase in ipairs(purchaseList) do | |||
table.insert(resultPart, p._getPurchaseStat(purchase, statName, displayInline)) | |||
end | |||
return table.concat(resultPart, ' or ') | |||
end | end | ||
end | end |