Модуль:Meals Lookup: различия между версиями
Mhamster (обсуждение | вклад) toolmade |
Mhamster (обсуждение | вклад) mixablerecipes |
||
| Строка 1: | Строка 1: | ||
local prototypes = mw.loadData("Module:Meals Lookup/data") | local prototypes = mw.loadData("Module:Meals Lookup/data") | ||
local | local chemicals = mw.loadData("Module:Chemistry Lookup/data").react | ||
local p = {} | local p = {} | ||
| Строка 6: | Строка 6: | ||
--#region universal | --#region universal | ||
function getrecipesfromtype(frame, type) -- should not be invoked | function getrecipesfromtype(frame, type) -- should not be invoked | ||
return p.meals[type] | return p.meals[type] | ||
| Строка 46: | Строка 47: | ||
--#region microwaveRecipes | --#region microwaveRecipes | ||
function getmicrowaverecipesolids(frame, recipe) -- should not be invoked | function getmicrowaverecipesolids(frame, recipe) -- should not be invoked | ||
local out = {} | local out = {} | ||
| Строка 131: | Строка 133: | ||
--#endregion heatableRecipes | --#endregion heatableRecipes | ||
--#region | --#region toolmadeRecipes | ||
function p.buildtoolmaderecipebox(frame) -- {{#invoke:Meals Lookup|buildtoolmaderecipebox|SliceableRecipeID}} | function p.buildtoolmaderecipebox(frame) -- {{#invoke:Meals Lookup|buildtoolmaderecipebox|SliceableRecipeID}} | ||
| Строка 147: | Строка 149: | ||
end | end | ||
--#endregion | --#endregion toolmadeRecipes | ||
--#region mixableRecipes | |||
function getchemicalreagents(recipe) | |||
local out = "" | |||
for ingredient, data in pairs(recipe["reactants"]) do | |||
out[ingredient] = data["amount"] | |||
end | |||
return out | |||
end | |||
function p.buildmixablerecipebox(frame) -- {{#invoke:Meals Lookup|buildmixablerecipebox|SliceableRecipeID}} | |||
local out = "" | |||
local id = frame.args[1]:gsub(' ', '') | |||
local recipe = chemicals[id] | |||
local input = buildreagents(frame, getchemicalreagents(recipe)) | |||
local output = recipe["effects"]["Entity"] | |||
local outamount = recipe["effects"]["Number"] | |||
out = frame:preprocess("{{Recipe Box" .. | |||
"| name = " .. | |||
"| component-1 = " .. input .. | |||
"|transformer={{Recipe Transformers|mixableRecipes}}".. | |||
"|result=".. frame:preprocess("{{Recipe Component|item={{#invoke:Entity Lookup|getname|".. output .."}}|image=File:Mousegif.gif|amount=".. outamount ).. | |||
"}}") | |||
-- out = frame:preprocess("{{Recipe Box".. | |||
-- "|name={{#invoke:Entity Lookup|getname|".. recipe["id"] .."}}".. | |||
-- "|component-1="..frame:preprocess("{{Recipe Component|item={{#invoke:Entity Lookup|getname|".. recipe["input"] .."}}|image=File:Mousegif.gif}}" ) .. | |||
-- "|transformer={{Recipe Transformers|".. transformer .."}}".. | |||
-- "|result=".. frame:preprocess("{{Recipe Component|item={{#invoke:Entity Lookup|getname|".. recipe["result"] .."}}|image=File:Mousegif.gif}}" ).. | |||
-- "}}") | |||
return out | |||
end | |||
--#endregion mixableRecipes | |||
| Строка 158: | Строка 194: | ||
out = out .. "\n" .. frame:preprocess("{{#invoke:Meals Lookup|buildheatrecipebox|".. frame.args[4] .. "}}") | out = out .. "\n" .. frame:preprocess("{{#invoke:Meals Lookup|buildheatrecipebox|".. frame.args[4] .. "}}") | ||
out = out .. "\n" .. frame:preprocess("{{#invoke:Meals Lookup|buildtoolmaderecipebox|".. frame.args[5] .. "}}") | out = out .. "\n" .. frame:preprocess("{{#invoke:Meals Lookup|buildtoolmaderecipebox|".. frame.args[5] .. "}}") | ||
out = out .. "\n" .. frame:preprocess("{{#invoke:Meals Lookup|buildmixablerecipebox|".. frame.args[6] .. "}}") | |||
return out | return out | ||
end | end | ||
return p | return p | ||