Module:Products: Difference between revisions

Jump to navigation Jump to search
Content added Content deleted
(Rename "item" parameter to "1", since many pages are using it like that anyways)
(Make limit a parameter; Make used item images smaller)
Line 14: Line 14:
local showPrices = yesno(args.showPrices)
local showPrices = yesno(args.showPrices)
local showValues = yesno(args.showValues)
local showValues = yesno(args.showValues)
local limit = tonumber(args.limit or 0) or 0
if limit <= 0 then
limit = 500
end


-- Query for data
-- Query for data
Line 20: Line 24:
'?Uses item',
'?Uses item',
'?Recipe JSON',
'?Recipe JSON',
showValues and '?Value',
'limit=500',
limit = limit
showValues and '?Value'
}
}
if not smw_data then
if not smw_data then
Line 68: Line 72:
-- Create table
-- Create table
local out = mw.html.create('table')
local out = mw.html.create('table')
:addClass('wikitable')
:addClass('wikitable align-right-1')
:tag('tr')
:tag('tr')
:tag('th')
:tag('th')
Line 123: Line 127:
for _, item in ipairs(recipe.materials) do
for _, item in ipairs(recipe.materials) do
ingredients:tag('li')
ingredients:tag('li')
:wikitext(('%s &times; [[File:%s.png|link=%s|30px]] [[%s]]'):format(item.quantity, item.name, item.name, item.name))
:wikitext(('%s &times; [[File:%s.png|link=%s|18px]] [[%s]]'):format(item.quantity, item.name, item.name, item.name))
:done()
:done()
end
end