Модуль:Meals Lookup: различия между версиями
Mhamster (обсуждение | вклад) Нет описания правки |
Mhamster (обсуждение | вклад) grindableRecipes |
||
| Строка 6: | Строка 6: | ||
--#region universal | --#region universal | ||
function | function getrecipetypes(type) -- should not be invoked | ||
return p.meals[type] | return p.meals[type] | ||
end | end | ||
function getrecipe( | function getrecipe(type, id) -- should not be invoked | ||
return | return getrecipetypes(type)[id:gsub(' ', '')] | ||
end | end | ||
function getrecipetypes( | function getrecipetypes(id) -- should not be invoked | ||
local out = {} | local out = {} | ||
for type, recipes in pairs(p.meals) do | for type, recipes in pairs(p.meals) do | ||
| Строка 26: | Строка 26: | ||
return out | return out | ||
end | end | ||
function buildsolids(frame, array) -- should not be invoked | |||
local out = "" | |||
for solid, amount in pairs(array) do | |||
out = out .. frame:preprocess( "{{Recipe Component|item={{#invoke:Entity Lookup|getname|".. solid .."}}|image=Файл:Mousegif.gif|amount=".. amount .."}}" ) | |||
end | |||
return out | |||
end | |||
function buildreagents(frame, array) -- should not be invoked | |||
local out = "" | |||
for item, amount in pairs(array) do | |||
out = out .. frame:preprocess( "{{Chem Recipe Component|reagent=".. item .."|amount={{{"..amount.."|1}}}}}" ) | |||
end | |||
return out | |||
end | |||
--#endregion | --#endregion | ||
| Строка 45: | Строка 63: | ||
end | end | ||
function p.buildmicrowaverecipebox(frame) -- {{#invoke:Meals Lookup|buildmicrowaverecipebox|MicrowaveRecipeID}} | function p.buildmicrowaverecipebox(frame) -- {{#invoke:Meals Lookup|buildmicrowaverecipebox|MicrowaveRecipeID}} | ||
local out = "" | local out = "" | ||
local id = frame.args[1]:gsub(' ', '') | local id = frame.args[1]:gsub(' ', '') | ||
local recipe = getrecipe( | local recipe = getrecipe("microwaveRecipes", id) | ||
local solids = buildsolids(frame, getmicrowaverecipesolids(frame, recipe)) | local solids = buildsolids(frame, getmicrowaverecipesolids(frame, recipe)) | ||
local reagents = buildreagents(frame, getmicrowaverecipereagents(frame, recipe)) | local reagents = buildreagents(frame, getmicrowaverecipereagents(frame, recipe)) | ||
| Строка 83: | Строка 85: | ||
local out = "" | local out = "" | ||
local id = frame.args[1]:gsub(' ', '') | local id = frame.args[1]:gsub(' ', '') | ||
local recipe = getrecipe( | local recipe = getrecipe("sliceableRecipes", id) | ||
out = frame:preprocess("{{Recipe Box".. | out = frame:preprocess("{{Recipe Box".. | ||
"|name={{#invoke:Entity Lookup|getname|".. recipe["result"] .."}}".. | "|name={{#invoke:Entity Lookup|getname|".. recipe["result"] .."}}".. | ||
| Строка 94: | Строка 96: | ||
--#endregion sliceableRecipes | --#endregion sliceableRecipes | ||
--#region grindableRecipes | |||
function p.buildmgrindrecipebox(frame) -- {{#invoke:Meals Lookup|buildmslicerecipebox|SliceableRecipeID}} | |||
local out = "" | |||
local id = frame.args[1]:gsub(' ', '') | |||
local recipe = getrecipe("sliceableRecipes", id) | |||
local result = buildreagents(frame, recipe["result"]) | |||
out = frame:preprocess("{{Recipe Box".. | |||
"|name={{#invoke:Entity Lookup|getname|".. recipe["result"] .."}}".. | |||
"|component-1="..frame:preprocess("{{Recipe Component|item={{#invoke:Entity Lookup|getname|".. recipe["input"] .."}}|image=Файл:Mousegif.gif}}" ) .. | |||
"|transformer={{Recipe Transformers|grindableRecipes}}".. | |||
"|result=".. result .. | |||
"}}") | |||
return out | |||
end | |||
--#endregion grindableRecipes | |||
-- tests. | -- tests. | ||
| Строка 100: | Строка 120: | ||
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 .. "\n" .. frame:preprocess("{{#invoke:Meals Lookup|buildmslicerecipebox|".. frame.args[2] .. "}}") | out = out .. "\n" .. frame:preprocess("{{#invoke:Meals Lookup|buildmslicerecipebox|".. frame.args[2] .. "}}") | ||
out = out .. "\n" .. frame:preprocess("{{#invoke:Meals Lookup|buildmgrindrecipebox|".. frame.args[3] .. "}}") | |||
-- out = out .. p.buildmicrowaverecipebox(frame, frame.args[1]) | -- out = out .. p.buildmicrowaverecipebox(frame, frame.args[1]) | ||
return out | return out | ||