Content added Content deleted
No edit summary |
No edit summary |
||
Line 2: | Line 2: | ||
local p = {} |
local p = {} |
||
local i = 0 |
|||
local subs = {} |
|||
p.getRecipe = function(frame) |
p.getRecipe = function(frame) |
||
Line 10: | Line 12: | ||
end |
end |
||
end |
end |
||
for k, v in ipairs(recipelist |
for k, v in ipairs(recipelist) do |
||
if type(v) == "table" then |
|||
⚫ | |||
i = i + 1 |
|||
subs[recipelist] = subs[recipelist] or {} |
|||
subs[recipelist][i] = k |
|||
⚫ | |||
end |
|||
end |
end |
||
txt = frame:expandTemplate{ title = 'Recipe', args = { result = output_name , ingredients = inputs} } |
txt = frame:expandTemplate{ title = 'Recipe', args = { result = output_name , ingredients = inputs} } |
Revision as of 20:24, 16 February 2022
Documentation for this module may be created at Module:Recipe/doc
local recipelist = mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{title='Template:Recipes.json'})
local p = {}
local i = 0
local subs = {}
p.getRecipe = function(frame)
local result = frame.args[1]
for k, v in pairs(recipelist) do
if v['output-name'] == result then
output_name = '[[Image:' .. 'veloren_' .. v['output-name'] .. '.png|link=]] ' .. v['output-name']
end
end
for k, v in ipairs(recipelist) do
if type(v) == "table" then
i = i + 1
subs[recipelist] = subs[recipelist] or {}
subs[recipelist][i] = k
inputs = k
end
end
txt = frame:expandTemplate{ title = 'Recipe', args = { result = output_name , ingredients = inputs} }
return txt
end
return p