Модуль:Meals Lookup: различия между версиями
Mhamster (обсуждение | вклад) Нет описания правки |
Mhamster (обсуждение | вклад) Нет описания правки |
||
| Строка 6: | Строка 6: | ||
function | function getrecipesfromtype(frame, type) -- {{#invoke:Meals Lookup|getrecipesfromtype|ProtoID}} | ||
return p.meals[type] | return p.meals[type] | ||
end | end | ||
function | function getrecipe(frame, type, id) -- should not be invoked | ||
return | return getrecipesfromtype(frame, type)[id:gsub(' ', '')] | ||
end | end | ||
function | function getmicrowaverecipesolids(frame, recipe) -- should not be invoked | ||
local out = {} | local out = {} | ||
for ingredient, amount in pairs(recipe["solids"]) do | for ingredient, amount in pairs(recipe["solids"]) do | ||
out[ingredient] = amount | out[ingredient] = amount | ||
end | end | ||
| Строка 23: | Строка 22: | ||
end | end | ||
function | function getmicrowaverecipereagents(frame, recipe) -- should not be invoked | ||
local out = {} | local out = {} | ||
for ingredient, amount in pairs(recipe["reagents"]) do | for ingredient, amount in pairs(recipe["reagents"]) do | ||
out[ingredient] = amount | out[ingredient] = amount | ||
end | end | ||
| Строка 32: | Строка 30: | ||
end | end | ||
function | function buildsolids(frame, array) -- should not be invoked | ||
local out = "" | local out = "" | ||
for solid, amount in pairs(array) do | for solid, amount in pairs(array) do | ||
| Строка 52: | Строка 50: | ||
local out = "hehe" | local out = "hehe" | ||
local id = frame.args[1]:gsub(' ', '') | local id = frame.args[1]:gsub(' ', '') | ||
local recipe = | local recipe = getrecipe(frame, "microwaveRecipes", id) | ||
local solids = | local solids = buildsolids(frame, getmicrowaverecipesolids(frame, recipe)) | ||
local reagents = p.buildreagents(frame, | local reagents = p.buildreagents(frame, getmicrowaverecipereagents(frame, recipe)) | ||
out = frame:preprocess("{{Recipe Box".. | out = frame:preprocess("{{Recipe Box".. | ||
"|name={{#invoke:Entity Lookup|getname|".. recipe["result"] .."}}".. | "|name={{#invoke:Entity Lookup|getname|".. recipe["result"] .."}}".. | ||
| Строка 61: | Строка 59: | ||
"|result=".. frame:preprocess("{{Recipe Component|item={{#invoke:Entity Lookup|getname|".. recipe["result"] .."}}|image=Файл:Mousegif.gif}}" ) .. | "|result=".. frame:preprocess("{{Recipe Component|item={{#invoke:Entity Lookup|getname|".. recipe["result"] .."}}|image=Файл:Mousegif.gif}}" ) .. | ||
"}}") | "}}") | ||
return out | return out | ||
end | end | ||
| Строка 86: | Строка 79: | ||
function p.tests(frame) | function p.tests(frame) | ||
local out = "" | local out = "" | ||
out = out . | out = out .. buildsolids(frame, getmicrowaverecipesolids(frame, getrecipe(frame, frame.args[2], frame.args[1]))) | ||
out = out .. "\n" .. p.buildreagents(frame, | out = out .. "\n" .. p.buildreagents(frame, getmicrowaverecipereagents(frame, getrecipe(frame, frame.args[2], frame.args[1]))) | ||
out = out .. "\n" .. frame:preprocess("{{#invoke:Meals Lookup|buildmicrowaverecipebox|".. frame.args[1] .. "}}") | out = out .. "\n" .. frame:preprocess("{{#invoke:Meals Lookup|buildmicrowaverecipebox|".. frame.args[1] .. "}}") | ||
-- out = out .. p.buildmicrowaverecipebox(frame, frame.args[1]) | -- out = out .. p.buildmicrowaverecipebox(frame, frame.args[1]) | ||