Module:Products: Difference between revisions

Jump to navigation Jump to search
Content added Content deleted
No edit summary
(extend module to work on data from Profession info as well as Infobox Recipe)
Line 34: Line 34:
limit = 500
limit = 500
end
end

-- Query for data
-- Query for data
local smw_data = mw.smw.ask{
local smw_data = mw.smw.ask{
'[[Uses item::' .. item .. ']]',
'[[Uses item::' .. item .. ']] OR [[Activity input::' .. item .. ']] OR [[Activity container::' .. item .. ']]',
'?Uses item',
'?Recipe JSON',
'?Recipe JSON',
'?Activity JSON',
showValues and '?Value',
showValues and '?Value',
limit = limit
limit = limit
Line 52: Line 52:
local produced_items = {}
local produced_items = {}
for _, product in ipairs(smw_data) do
for _, product in ipairs(smw_data) do
local jsons = product['Recipe JSON']
local jsons = product['Recipe JSON'] or product['Activity JSON']
if type(jsons) == 'string' then
if type(jsons) == 'string' then
jsons = { jsons }
jsons = { jsons }
Line 126: Line 126:
:tag('th')
:tag('th')
:attr{ colspan = '3' }
:attr{ colspan = '3' }
:wikitext('Recipe')
:wikitext('Product')
:done()
:done()
:tag('th'):wikitext('Level'):done()
:tag('th'):wikitext('Level'):done()
Line 132: Line 132:
:tag('th'):wikitext('Value'):done()
:tag('th'):wikitext('Value'):done()
:END()
:END()
:tag('th'):wikitext('Ingredients'):done()
:tag('th'):wikitext('Inputs'):done()
:IF(showPrices)
:IF(showPrices)
:tag('th'):wikitext('Price'):done()
:tag('th'):wikitext('Price'):done()